Unless I am missing something simple, which is totally possible, I wish it was
that easy.
The KML definition has, for the first point:
<longitude>53.27419355426855</longitude>
<latitude>27.67482351137865</latitude>
I set a breakpoint in my code right after this statement:
SimpleFeature f = (SimpleFeature) parser.parse(
inputStream );
When I examined f, I saw:
Geometry<Geometry id=fid-5212f72_14c2d07503c_-7ffb>=POINT
(27.67482351137865 53.27419355426855)],
So it is obviously treating it as lat/lon.
When I get to the point in the code where I extract the Geometry object, it
sees it as lon/lat, rather than lat/lon.
I need a way to tell geotools that I am using the x,y,z convention for my
geometries. I would rather have it come out of the KML in lon/lat order instead
of lat/lon.
______________________________________
Randall S. (Randy) Avis
Senior Software Engineer
KEYW Corporation
571-421-8566 (office)
703-609-7837 (cell)
ra...@keywcorp.com<mailto:ra...@keywcorp.com>
From: Ian Turton [mailto:ijtur...@gmail.com]
Sent: Wednesday, March 18, 2015 9:10 AM
To: Randall S. Avis; geotools-gt2-users@lists.sourceforge.net
Subject: Re: [Geotools-gt2-users] KML consumption Lat/Lon issue
Randall,
The problem is that lat/lon is the correct order for geographers. If you take
the features that the KML parser gives you and use the GeoTools PostGIS
datastore to write them into postgis then everything will just work.
Your confusion comes from using JTS to look at the coordinates en route.
Ian
On Wed, Mar 18, 2015 at 12:11 PM Randall S. Avis
<ra...@keywcorp.com<mailto:ra...@keywcorp.com>> wrote:
Forgive my personal density. I’m a casual user of geotools at best.
We are not using MapServer or anything of the sort. We are developing a website
that allows users to upload KML and other geographic data, parse and enhance
the contents, and store it in PostGIS. We want to use geotools because the KML
parser allows us to easily consume the input and convert it to a jts Geometry
object, which can be directly deposited into the database. We just use geotools
as an add-in to parse the KML. The example code came directly from the geotools
documentation, and that’s really all the code I have. I just can’t find a way
to tell it to use lon/lat instead of lat/lon.
InputStream inputStream = new
FileInputStream(file);
Parser parser = new Parser(new
KMLConfiguration());
SimpleFeature f = (SimpleFeature) parser.parse(
inputStream );
Collection<SimpleFeature> features =
(Collection<SimpleFeature>) f.getAttribute("Feature");
______________________________________
Randall S. (Randy) Avis
Senior Software Engineer
KEYW Corporation
571-421-8566 (office)
703-609-7837 (cell)
ra...@keywcorp.com<mailto:ra...@keywcorp.com>
From: Jody Garnett
[mailto:jody.garn...@gmail.com<mailto:jody.garn...@gmail.com>]
Sent: Tuesday, March 17, 2015 4:30 PM
To: Randall S. Avis
Cc:
geotools-gt2-users@lists.sourceforge.net<mailto:geotools-gt2-users@lists.sourceforge.net>
Subject: Re: [Geotools-gt2-users] KML consumption Lat/Lon issue
It may depend a bit on the srs name, if you are using the full "URI" form then
the values will be as provided in the EPSG database.
You may wish to use the WMS srs name "CRS:84" which is always in the correct
order (since it is formally defined that way). See
http://gis.stackexchange.com/questions/54073/what-is-crs84-projection for
details.
--
Jody
--
Jody
--
Jody Garnett
On 17 March 2015 at 05:12, Randall S. Avis
<ra...@keywcorp.com<mailto:ra...@keywcorp.com>> wrote:
All;
I’ve been working with the parser to open and read KML files, and produce jts
Geometries. The examples I found on the geotools site and elsewhere make it
relatively simple except that the latitude and longitude are reversed from the
values in the KML.
I found the documentation entry
(http://docs.geotools.org/latest/userguide/library/referencing/order.html) that
says to set the forceXY property to true, but that does not seem to work. I’m
running a web application using Spring 4 and have tried inserting the
System.setProperty call in the constructor method for my geotools service, and
I found a sample to put in my application.xml file, but neither force the
lon/lat format on the output. Here’s the setup code:
InputStream inputStream = new
FileInputStream(file);
Parser parser = new Parser(new
KMLConfiguration());
SimpleFeature f = (SimpleFeature) parser.parse(
inputStream );
Collection<SimpleFeature> features =
(Collection<SimpleFeature>) f.getAttribute("Feature");
By the time I get to the third step, everything has been parsed as lat/lon. I
don’t see any arguments for the KMLConfiguration() that would allow me to
specify the forceXY or anything else.
I’m using geotools 12.2. Does anyone have any suggestions?
______________________________________
Randall S. (Randy) Avis
Senior Software Engineer
KEYW Corporation
571-421-8566<tel:571-421-8566> (office)
703-609-7837<tel:703-609-7837> (cell)
ra...@keywcorp.com<mailto:ra...@keywcorp.com>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net<mailto:GeoTools-GT2-Users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now.
http://goparallel.sourceforge.net/_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net<mailto:GeoTools-GT2-Users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users