geospatial - Document DB Location Query -


my data looks this:

    {   "id": "a06b42cf-d130-459a-8c89-dab77966747c",   "propertybag": {         "fixed": {       "address": {         "locationname": "",         "addressline1": "1 microsoft way",         "addressline2": null,         "city": "redmond",         "postalcode": "98052",         "subdivision": null,         "state": "wa",         "country": "usa",         "location": {           "type": "point",           "coordinates": [             47.640049,             -122.129797           ]         }       },      }   } } 

now when try query this

select * v v  st_distance(v.propertybag.fixed.address.location, {      "type": "point",      "coordinates": [47.36, -122.19]      }) < 100 * 1000 

the results empty. wondering if can please let me know maybe wrong?

i suspect have logitude , latitude transposed. because if change document to:

"location": {   "type": "point",   "coordinates": [-122.129797, 47.640049] } 

and run query:

select    st_distance(v.propertybag.fixed.address.location, {      "type": "point",      "coordinates": [-122.19, 47.36]    }) v 

i result, if run way show, no results.

in geojson, points specified [longitude, latitude] make match our normal expectations of x being east-west, , y being north-south. unfortunately, opposite of traditional way of showing geo coordinates.

-122 not valid value latitude. range latitude -90 +90. longitude specified -180 +180.

if database populated , don't feel migrating it, use user defined function (udf) fix during query recommend doing migration on approach because geo-spacial indexes won't work have , queries slower result.

again, don't recommend unless geo index not important, here swapxy udf swap:

function(point) {      return {         type: "point",         coordinates: [point.coordinates[1], point.coordinates[0]]     }; } 

you use in query this:

select * v       st_distance(         udf.swapxy(v.propertybag.fixed.address.location),          udf.swapxy({           "type": "point",           "coordinates": [47.36, -122.19]          })     ) < 100 * 1000 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -