Hi All,
I am writing a feature that will rely on geo:distance to give me the distance between two points of latitude and longitude.
I am a total n00b to GIS and GML so I may have messed this up, but based on a bit of research to figure out how to define the coordinate system and based on the example query from the BaseX docs I came up with the following query as a test:
import module namespace geo = "http://expath.org/ns/geo"; declare namespace gml='http://www.opengis.net/gml';
let $vancouver := <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos49.40 -123.26</gml:pos> </gml:Point>
let $seattle := <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos47.68 -122.37</gml:pos> </gml:Point>
return geo:distance($vancouver, $seattle)
I have this in a file and am trying to execute it from the CLI with: 'RUN [/path/to/file]'
It pukes with this error:
Stopped at [/path/to/file], 12/21: [GEO:GEO0002] java.lang.NullPointerException
I am running off of the zip distribution of BaseX so I believe the geo module should be included.
Any guidance would be greatly appreciated.
Best, -Jesse
Hi Jesse,
BaseX only supports GML 2, and AFAIK gml:pos was not introduced until GML 3. You need to use gml:coordinate instead (which uses a comma instead of a space as a delimiter). This works for me:
import module namespace geo = "http://expath.org/ns/geo"; declare namespace gml='http://www.opengis.net/gml';
let $vancouver := <gml:Point srsDimension="2" srsName=" http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:coordinates49.40,-123.26</gml:coordinates> </gml:Point>
let $seattle := <gml:Point srsDimension="2" srsName=" http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:coordinates47.68,-122.37</gml:coordinates> </gml:Point>
return geo:distance($vancouver, $seattle)
Also, I would think you would want to format the coordinates as longitude, latitude, however the result is the same (1.9366207682455534) either way. I don't think your SRS information is being handled properly, but sorry I don't really know anything about that.
Zach
On Wed, Mar 26, 2014 at 5:49 PM, Jesse Clark jesse@corengi.com wrote:
Hi All,
I am writing a feature that will rely on geo:distance to give me the distance between two points of latitude and longitude.
I am a total n00b to GIS and GML so I may have messed this up, but based on a bit of research to figure out how to define the coordinate system and based on the example query from the BaseX docshttp://docs.basex.org/wiki/Geo_Module#geo:distance I came up with the following query as a test:
import module namespace geo = "http://expath.org/ns/geo"; declare namespace gml='http://www.opengis.net/gml';
let $vancouver := <gml:Point srsDimension="2" srsName=" http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos49.40 -123.26</gml:pos> </gml:Point>
let $seattle := <gml:Point srsDimension="2" srsName=" http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos47.68 -122.37</gml:pos> </gml:Point>
return geo:distance($vancouver, $seattle)
I have this in a file and am trying to execute it from the CLI with: 'RUN [/path/to/file]'
It pukes with this error:
Stopped at [/path/to/file], 12/21: [GEO:GEO0002] java.lang.NullPointerException
I am running off of the zip distribution of BaseX so I believe the geo module should be included.
Any guidance would be greatly appreciated.
Best, -Jesse
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Jesse,
as Zachary thankfully pointed out, our implementation only supports GML 2.0. It is based on the JTS library [1], which seems to return a NullPointerException for geo elements that do not comply with 2.0. I've slightly updated the error message [2] to make clearer what's going on.
Best, Christian
[1] http://www.vividsolutions.com/jts/JTSHome.htm [2] http://files.basex.org/releases/latest/ ________________________________________________
On Wed, Mar 26, 2014 at 10:49 PM, Jesse Clark jesse@corengi.com wrote:
Hi All,
I am writing a feature that will rely on geo:distance to give me the distance between two points of latitude and longitude.
I am a total n00b to GIS and GML so I may have messed this up, but based on a bit of research to figure out how to define the coordinate system and based on the example query from the BaseX docshttp://docs.basex.org/wiki/Geo_Module#geo:distance I came up with the following query as a test:
import module namespace geo = "http://expath.org/ns/geo"; declare namespace gml='http://www.opengis.net/gml';
let $vancouver := <gml:Point srsDimension="2" srsName=" http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos49.40 -123.26</gml:pos> </gml:Point>
let $seattle := <gml:Point srsDimension="2" srsName=" http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos47.68 -122.37</gml:pos> </gml:Point>
return geo:distance($vancouver, $seattle)
I have this in a file and am trying to execute it from the CLI with: 'RUN [/path/to/file]'
It pukes with this error:
Stopped at [/path/to/file], 12/21: [GEO:GEO0002] java.lang.NullPointerException
I am running off of the zip distribution of BaseX so I believe the geo module should be included.
Any guidance would be greatly appreciated.
Best, -Jesse
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Thanks for the info guys.
GML 2.0 does support srs attributes according to the spec (and JTS claims to too according to that spec).
But I'm not sure if my srsName declaration is having any effect. Using 69.1 miles per degree of latitude (assuming the result is in degrees of latitude) gives 133.8 miles and the actual distance is 141.0. This difference could be due to using a 2d projection instead of spherical.
Zachary you were correct about the coordinate order. It should be long,lat.
Either way, not being familiar with GML or GIS this is all getting way to complicated for me as a method to find the distance in miles between two coordinates of lat/lng. I am just going to use an implementation of the Haversine function in my app to calculate the distances I need.
Thanks again, -Jesse
On Mar 27, 2014, at 3:26 AM, Christian Grün christian.gruen@gmail.com wrote:
Hi Jesse,
as Zachary thankfully pointed out, our implementation only supports GML 2.0. It is based on the JTS library [1], which seems to return a NullPointerException for geo elements that do not comply with 2.0. I’ve slightly updated the error message [2] to make clearer what’s going on.
Best, Christian
[1] http://www.vividsolutions.com/jts/JTSHome.htm [2] http://files.basex.org/releases/latest/ ________________________________________________
On Wed, Mar 26, 2014 at 10:49 PM, Jesse Clark jesse@corengi.com wrote: Hi All,
I am writing a feature that will rely on geo:distance to give me the distance between two points of latitude and longitude.
I am a total n00b to GIS and GML so I may have messed this up, but based on a bit of research to figure out how to define the coordinate system and based on the example query from the BaseX docs I came up with the following query as a test:
import module namespace geo = "http://expath.org/ns/geo"; declare namespace gml='http://www.opengis.net/gml';
let $vancouver := <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos49.40 -123.26</gml:pos> </gml:Point>
let $seattle := <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos47.68 -122.37</gml:pos> </gml:Point>
return geo:distance($vancouver, $seattle)
I have this in a file and am trying to execute it from the CLI with: 'RUN [/path/to/file]'
It pukes with this error:
Stopped at [/path/to/file], 12/21: [GEO:GEO0002] java.lang.NullPointerException
I am running off of the zip distribution of BaseX so I believe the geo module should be included.
Any guidance would be greatly appreciated.
Best, -Jesse
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Just to correct myself the actual distance should be 125.6. :)
On Mar 27, 2014, at 11:05 AM, Jesse Clark jesse@corengi.com wrote:
Thanks for the info guys.
GML 2.0 does support srs attributes according to the spec (and JTS claims to too according to that spec).
But I'm not sure if my srsName declaration is having any effect. Using 69.1 miles per degree of latitude (assuming the result is in degrees of latitude) gives 133.8 miles and the actual distance is 141.0. This difference could be due to using a 2d projection instead of spherical.
Zachary you were correct about the coordinate order. It should be long,lat.
Either way, not being familiar with GML or GIS this is all getting way to complicated for me as a method to find the distance in miles between two coordinates of lat/lng. I am just going to use an implementation of the Haversine function in my app to calculate the distances I need.
Thanks again, -Jesse
On Mar 27, 2014, at 3:26 AM, Christian Grün christian.gruen@gmail.com wrote:
Hi Jesse,
as Zachary thankfully pointed out, our implementation only supports GML 2.0. It is based on the JTS library [1], which seems to return a NullPointerException for geo elements that do not comply with 2.0. I’ve slightly updated the error message [2] to make clearer what’s going on.
Best, Christian
[1] http://www.vividsolutions.com/jts/JTSHome.htm [2] http://files.basex.org/releases/latest/ ________________________________________________
On Wed, Mar 26, 2014 at 10:49 PM, Jesse Clark jesse@corengi.com wrote: Hi All,
I am writing a feature that will rely on geo:distance to give me the distance between two points of latitude and longitude.
I am a total n00b to GIS and GML so I may have messed this up, but based on a bit of research to figure out how to define the coordinate system and based on the example query from the BaseX docs I came up with the following query as a test:
import module namespace geo = "http://expath.org/ns/geo"; declare namespace gml='http://www.opengis.net/gml';
let $vancouver := <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos49.40 -123.26</gml:pos> </gml:Point>
let $seattle := <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326%22%3E gml:pos47.68 -122.37</gml:pos> </gml:Point>
return geo:distance($vancouver, $seattle)
I have this in a file and am trying to execute it from the CLI with: 'RUN [/path/to/file]'
It pukes with this error:
Stopped at [/path/to/file], 12/21: [GEO:GEO0002] java.lang.NullPointerException
I am running off of the zip distribution of BaseX so I believe the geo module should be included.
Any guidance would be greatly appreciated.
Best, -Jesse
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de