I am having a json object as
area : CIRCLE (28.625360369528934 77.2227479486792, 3135.6)
how to parse it using WKTreader?
I am having a json object as
area : CIRCLE (28.625360369528934 77.2227479486792, 3135.6)
how to parse it using WKTreader?
You need to go back to whoever wrote it out and explain the CIRCLE
is not a part of the WKT standard and they should stop producing it.
Your best bet then is to generate a polygon with a lot (200) sides that approximates the circle, probably using the JTS buffer method.
Point p = gFactory.createPoint(28.625360369528934 77.2227479486792);
Polygon circle = p.buffer( 3135.6 );
CircularString
WKT, example: CIRCULARSTRING(4 1, 7 4, 4 7, 1 4, 4 1)
. See this link for more examples. You can wrap it in a CompoundCurve
to get a surface out of it. –
Ungainly Another option is to accept a central point and a radius. This will allow you to determine if another geographic shape is within 'the zone' or nearby.
{
"wkt": "POINT(28.625360369528934 77.2227479486792)",
"radius": 50
}
This is slightly more elegant than generating hundreds of points as you have a completely lossless articulation of the circle. The only time it would be better to convert into a polygon is if the share is not a perfect circle (then this approach would be 'lossy').
© 2022 - 2024 — McMap. All rights reserved.