Giter VIP home page Giter VIP logo

rtree-distance's Introduction

Find overlapping spatial bounding boxes with calculated distance using rtree

How it works

On startup the base data is loaded and a spatial index is built and persisted using rtree. On next startup (if disk is persistent), it will only do an incremental update.

Spatial matching is done using bounding box intersection.

Transit decoding is supported.

This example matches lines to lines (bounding box is then a square around the line).

Example system config:

{
  "_id": "my-spatial-mapper-transformer",
  "type": "system:microservice",
  "docker": {
    "environment": {
      "SOURCE_PROPERTY": "geometry",
      "TARGET_PROPERTY": "matches",
      "BASE_DATA_URL": "https://datahub-8aba61d1.sesam.cloud/api/publishers/geomapping-vegreferanse-endpoint/entities",
      "BASE_DATA_PROPERTY": "geojson"
    },
    "image": "sesamcommunity/rtree-distance",
    "port": 5000
  }
}

Example base data:

[
  {
    "_id": "nvdb_532:2742201",
    "geojson": {
      "coordinates": [
        [
          "~f20.275140075413407",
          "~f69.3655151720329"
        ],
        [
          "~f20.27540808104736",
          "~f69.36550547509162"
        ],
        [
          "~f20.275606019523785",
          "~f69.36549818308787"
        ],
        [
          "~f20.275741111471955",
          "~f69.3654936159889"
        ],
        [
          "~f20.27588473353304",
          "~f69.36548950852044"
        ],
        [
          "~f20.276088610630637",
          "~f69.36548563357877"
        ],
        [
          "~f20.27625265627205",
          "~f69.36548576143353"
        ],
        [
          "~f20.276417427103247",
          "~f69.36548676668413"
        ],
        [
          "~f20.27661799098933",
          "~f69.36549018936122"
        ],
        [
          "~f20.276847024473764",
          "~f69.36549841176996"
        ],
        [
          "~f20.27695146856492",
          "~f69.36550305484138"
        ],
        [
          "~f20.277169993797635",
          "~f69.36551627539028"
        ],
        [
          "~f20.27733668486062",
          "~f69.3655292766408"
        ],
        [
          "~f20.277478795205802",
          "~f69.36554293718855"
        ],
        [
          "~f20.277641176564018",
          "~f69.36556020797542"
        ],
        [
          "~f20.27781488946667",
          "~f69.3655820812377"
        ],
        [
          "~f20.277988302822685",
          "~f69.36560585275025"
        ],
        [
          "~f20.278156803137428",
          "~f69.36563247288133"
        ],
        [
          "~f20.27831759590821",
          "~f69.36566094726851"
        ],
        [
          "~f20.278510285789643",
          "~f69.36569987452037"
        ],
        [
          "~f20.27858866042266",
          "~f69.36571574763427"
        ],
        [
          "~f20.278676697218472",
          "~f69.36573357521803"
        ],
        [
          "~f20.278771520735862",
          "~f69.36575515429723"
        ],
        [
          "~f20.278861796581058",
          "~f69.3657779516049"
        ],
        [
          "~f20.27895263230716",
          "~f69.3658019913189"
        ],
        [
          "~f20.27907991043613",
          "~f69.36583733490951"
        ],
        [
          "~f20.279246135727046",
          "~f69.36588795438387"
        ],
        [
          "~f20.27938934901656",
          "~f69.36593522708651"
        ],
        [
          "~f20.279540391151976",
          "~f69.36598945818953"
        ],
        [
          "~f20.279644832089705",
          "~f69.36603152565834"
        ],
        [
          "~f20.279742943656725",
          "~f69.3660737861238"
        ],
        [
          "~f20.27980022620436",
          "~f69.36610037825761"
        ],
        [
          "~f20.279861226006965",
          "~f69.36612964594194"
        ],
        [
          "~f20.279924952231646",
          "~f69.36616170936162"
        ],
        [
          "~f20.280008442733532",
          "~f69.36620675478515"
        ],
        [
          "~f20.28009705496678",
          "~f69.366258121507"
        ],
        [
          "~f20.280151489049825",
          "~f69.36629181778416"
        ],
        [
          "~f20.280204744929918",
          "~f69.36632590985143"
        ],
        [
          "~f20.280253290188767",
          "~f69.36635951583298"
        ],
        [
          "~f20.2803018985929",
          "~f69.36639545899605"
        ],
        [
          "~f20.28034853499839",
          "~f69.36643272182751"
        ],
        [
          "~f20.280391364032123",
          "~f69.36646902119712"
        ],
        [
          "~f20.280439346259428",
          "~f69.36651281048248"
        ],
        [
          "~f20.280472206429955",
          "~f69.36654590525296"
        ],
        [
          "~f20.280523004546684",
          "~f69.36660013465838"
        ],
        [
          "~f20.280579889756417",
          "~f69.36667190168896"
        ],
        [
          "~f20.280604939699693",
          "~f69.36670955306568"
        ],
        [
          "~f20.280636208047106",
          "~f69.36676527786521"
        ],
        [
          "~f20.280658846938017",
          "~f69.36681181946481"
        ],
        [
          "~f20.280688732643057",
          "~f69.36688998799649"
        ],
        [
          "~f20.28070239920652",
          "~f69.36694570993996"
        ],
        [
          "~f20.280718419545913",
          "~f69.36702870977498"
        ],
        [
          "~f20.280725804497674",
          "~f69.36713266523584"
        ],
        [
          "~f20.28072548697966",
          "~f69.36720833640803"
        ],
        [
          "~f20.280726035932155",
          "~f69.36728650019931"
        ],
        [
          "~f20.280726043692326",
          "~f69.36734893643276"
        ],
        [
          "~f20.280728085297383",
          "~f69.36744774689319"
        ],
        [
          "~f20.28073158579835",
          "~f69.36754210451245"
        ],
        [
          "~f20.28074673092454",
          "~f69.36766417634247"
        ],
        [
          "~f20.280778586166996",
          "~f69.36780445139269"
        ],
        [
          "~f20.280805529847452",
          "~f69.36788621837262"
        ],
        [
          "~f20.280824841770276",
          "~f69.36793583035858"
        ],
        [
          "~f20.28085541238843",
          "~f69.36800534127718"
        ],
        [
          "~f20.28088705449963",
          "~f69.36807127376552"
        ],
        [
          "~f20.28092697022725",
          "~f69.36814314569577"
        ],
        [
          "~f20.28095913268232",
          "~f69.36819938303397"
        ],
        [
          "~f20.280990910667857",
          "~f69.36825509230209"
        ],
        [
          "~f20.281011802272083",
          "~f69.36829242070549"
        ],
        [
          "~f20.28104275604641",
          "~f69.36833852873808"
        ],
        [
          "~f20.281082057412775",
          "~f69.36839994626261"
        ],
        [
          "~f20.281125372883203",
          "~f69.36847356669216"
        ],
        [
          "~f20.281159781185153",
          "~f69.36853063516992"
        ],
        [
          "~f20.281212357837383",
          "~f69.36862016697921"
        ],
        [
          "~f20.28127354032727",
          "~f69.36873021843424"
        ],
        [
          "~f20.281301621496432",
          "~f69.36878541069886"
        ],
        [
          "~f20.28134535588571",
          "~f69.36887737142999"
        ],
        [
          "~f20.28136771835772",
          "~f69.3689279699432"
        ],
        [
          "~f20.281395049314874",
          "~f69.36899362116704"
        ],
        [
          "~f20.281421770830377",
          "~f69.36907134644937"
        ],
        [
          "~f20.28144266195296",
          "~f69.36913674430049"
        ],
        [
          "~f20.281460693006736",
          "~f69.369191523429"
        ],
        [
          "~f20.28147486518692",
          "~f69.36924201193688"
        ],
        [
          "~f20.281486970379174",
          "~f69.36929031434795"
        ],
        [
          "~f20.281498649059504",
          "~f69.36934519730187"
        ],
        [
          "~f20.28150884900775",
          "~f69.36941173100467"
        ]
      ],
      "type": "LineString"
    }
  }
]

Example transform input:

[
  {
    [..]
    "geometry": {
      "type": "LineString",
      "coordinates": [
        [
          20.280643299568673,
          69.3668543408985
        ],
        [
          20.279440088198896,
          69.36610949576483
        ]
      ]
    }
  }
]

Example transform output:

  {
    [..]
    "matches": [
      {
        "_id": "nvdb_532:2742201",
        "distance": 2.970718302844068e-05
      }
    ]
  }

rtree-distance's People

Contributors

baardbouvet avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rtree-distance's Issues

Support deletes in base data

Should support handling of deleted entities in the base data. rtree supports "Delete", but then the id in the index has to be an integer derived from the "_id" property (or some other property that will be part of the deletion marker).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.