geotools-gt2-users

 [Geotools-gt2-users] creating coordinates in JTS using gps data From: ari fainchtein - 2009-01-19 04:57:02 ```Hello, I just started playing with JTS and Geotools. The question I have is, is I have a GPS unit that give info as Long and Lat with values as S144 23.456, E 28 88.123, how do I create coordinates to create geometries in JTS? thanks ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: Michael Bedward - 2009-01-19 08:05:01 ```Hi Ari, Are you asking about some aspect of converting from lat-long to a rectangular coordinate system prior to creating geometries ? (I saw your earlier question about lat/long -> utm) Are you wondering how to deal with the specific format of the values from your GPS ? (in which case, what does 28 88.123 mean ?) Sorry if I'm missing something obvious... Michael ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: ari fainchtein - 2009-01-19 14:44:26 ```Yes. I want to write code so that I can walk around my farm with a gps unit, locate coordinates for every building to create a 2D diagram. My gps unit gives me values like S37 28.123 it means 37degrees 28.123. Since my app is web based, I need to be able to generate diagrams in an X-Y coordinate system. Therefore the question on how to create a geometry from data coming from a gps unit. Any suggestions on how to do that? On 19/01/2009, at 0:04, "Michael Bedward" wrote: > Hi Ari, > > Are you asking about some aspect of converting from lat-long to a > rectangular coordinate system prior to creating geometries ? (I saw > your earlier question about lat/long -> utm) > > Are you wondering how to deal with the specific format of the values > from your GPS ? > (in which case, what does 28 88.123 mean ?) > > Sorry if I'm missing something obvious... > > Michael > ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: Michael Bedward - 2009-01-20 03:17:35 ```Hi Ari, Well, before talking code - can you configure you gps to record UTM coords ? I've only used a few but they all allowed setting the datum and projection. Michael 2009/1/20 ari fainchtein : > Yes. I want to write code so that I can walk around my farm with a gps unit, > locate coordinates for every building to create a 2D diagram. My gps unit > gives me values like S37 28.123 it means 37degrees 28.123. Since my app is > web based, I need to be able to generate diagrams in an X-Y coordinate > system. Therefore the question on how to create a geometry from data coming > from a gps unit. Any suggestions on how to do that? > > On 19/01/2009, at 0:04, "Michael Bedward" wrote: > >> Hi Ari, >> >> Are you asking about some aspect of converting from lat-long to a >> rectangular coordinate system prior to creating geometries ? (I saw >> your earlier question about lat/long -> utm) >> >> Are you wondering how to deal with the specific format of the values >> from your GPS ? >> (in which case, what does 28 88.123 mean ?) >> >> Sorry if I'm missing something obvious... >> >> Michael >> > ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: ari fainchtein - 2009-01-20 15:12:54 ```Thanks for that. Even if my garmin61 gives me utm, how do I create polygons from utm or latitude long ? On 19/01/2009, at 21:17, "Michael Bedward" wrote: > Hi Ari, > > Well, before talking code - can you configure you gps to record UTM > coords ? I've only used a few but they all allowed setting the datum > and projection. > > Michael > > > 2009/1/20 ari fainchtein : >> Yes. I want to write code so that I can walk around my farm with a >> gps unit, >> locate coordinates for every building to create a 2D diagram. My >> gps unit >> gives me values like S37 28.123 it means 37degrees 28.123. Since my >> app is >> web based, I need to be able to generate diagrams in an X-Y >> coordinate >> system. Therefore the question on how to create a geometry from >> data coming >> from a gps unit. Any suggestions on how to do that? >> >> On 19/01/2009, at 0:04, "Michael Bedward" >> wrote: >> >>> Hi Ari, >>> >>> Are you asking about some aspect of converting from lat-long to a >>> rectangular coordinate system prior to creating geometries ? (I saw >>> your earlier question about lat/long -> utm) >>> >>> Are you wondering how to deal with the specific format of the values >>> from your GPS ? >>> (in which case, what does 28 88.123 mean ?) >>> >>> Sorry if I'm missing something obvious... >>> >>> Michael >>> >> > ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: Michael Bedward - 2009-01-21 02:16:28 ```Firstly, I'm not sure what data format(s) your gps exports, but if GPX is one of them I suggest you have a look at the new gpx package... http://javadoc.geotools.fr/2.5/org/geotools/data/gpx/package-summary.html I haven't used this package but it may well do a lot of what you need. Meanwhile, if you are working with raw data, creating polygons "by hand" each of your farm buildings from corner/vertex coords is very straightforward... /// warning - mixture of pseudo code and java ! GeometryFactory gf = new GeometryFactory(); List polys = new ArrayList(); for each building... { int nv = ... numer of vertices in this building Coordinate[] vertices = new Coordinate[nv + 1] int k = 0; for each vertex with ordinates x, y { vertices[k++] = new Coordinate(x, y); } vertices[k] = vertices[0]; // end vertex == start vertex to 'close' polygon Polygon poly = new gf.createPolygon(gf.createLinearRing(vertices), null); polys.add(poly); } For GeometryFactory, Polygon and Coordinate classes see the docs at: http://tsusiatsoftware.net/jts/javadoc/index.html Michael ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: ari fainchtein - 2009-01-21 23:22:25 ```M, thanks for the code. in it you say: vertices[k++] = new Coordinate(x, y); where x and y are of type double. however, since my gps gives me data in the form of 144 12.345 where the 144 is degrees and the 12.345 is minutes, how do i create coordinates if the constructor takes doubles? On 20/01/2009, at 8:16 PM, Michael Bedward wrote: > Firstly, I'm not sure what data format(s) your gps exports, but if GPX > is one of them I suggest you have a look at the new gpx package... > http://javadoc.geotools.fr/2.5/org/geotools/data/gpx/package-summary.html > > I haven't used this package but it may well do a lot of what you need. > > Meanwhile, if you are working with raw data, creating polygons "by > hand" each of your farm buildings from corner/vertex coords is very > straightforward... > > /// warning - mixture of pseudo code and java ! > > GeometryFactory gf = new GeometryFactory(); > List polys = new ArrayList(); > for each building... { > int nv = ... numer of vertices in this building > Coordinate[] vertices = new Coordinate[nv + 1] > int k = 0; > for each vertex with ordinates x, y { > vertices[k++] = new Coordinate(x, y); > } > vertices[k] = vertices[0]; // end vertex == start vertex to > 'close' polygon > > Polygon poly = new > gf.createPolygon(gf.createLinearRing(vertices), null); > polys.add(poly); > } > > For GeometryFactory, Polygon and Coordinate classes see the docs at: > http://tsusiatsoftware.net/jts/javadoc/index.html > > Michael > ```
 Re: [Geotools-gt2-users] creating coordinates in JTS using gps data From: Michael Bedward - 2009-01-21 23:54:48 ```> where x and y are of type double. however, since my gps gives me data in > the form of 144 12.345 where the 144 is degrees and the 12.345 is minutes, > how do i create coordinates if the constructor takes doubles? This is how I would do it... double toDecimalDeg(double deg, double min) { int sign = deg < 0 ? -1 : 1; double decDeg = Math.abs(deg) + min / 60; return decDeg * sign; } Michael ```