Reputation: 2168
I might confuse between two things, but I need to do some calculation on my polygons (distance, area etc.). Using the WKBReader, I'm getting the geo:
WKBReader wkbReader = new WKBReader();
byte[] a = results.getBytes(8);
Geometry geo = wkbReader.read(results.getBytes("st_asbinary"));
But I'm not getting it in EPSG:4326. I want to use GeoTools to do the transform. How do I get the CRS from the geo object? (look at the 3 question marks)
CoordinateReferenceSystem sourceCRS = ???
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); Geometry targetGeometry = JTS.transform(geo, transform); Any help will be appreciated.
Upvotes: 2
Views: 3027
Reputation: 7529
If a CRS value is set on the geo object then the appropriate method call is:
geo.getCoordinateReferenceSystem()
If it isn't set on the geometry then you'll need to find a suitable object to get it from. The GeoTools Geometry CRS Tutorial has some examples (schema, world) and the GeoTools JavaDoc has a complete list of getCoordinateReferenceSystem() method declarations/implementations.
Upvotes: 1