This is what use to get a circle:
GeometricShapeFactory shape = new GeometricShapeFactory(gf);
shape.setCentre(new Coordinate(40.748754,-73.985460));//Empire Sate Building
shape.setSize(2* (10*0.009));//expect 10km radius
shape.setNumPoints(64);
final Polygon circle = shape.createEllipse();//createCircle deprecated
What I get is a weird ellipse. I know that closer to the equator we get 'more perfect' circle but still, is it valid circle for radius of 10km
with ESB
as a center point ?
Reading Dr. Ian Turton posts, github repo, and other great materials he shares, I know that I can use geotools
and do that differently but I would like to stick with that approach.
EDITED:
I am writting an application. In MySQL
I store mall
s with their location
(spatial type Point
). What I want to do is to get malls from db that are in a certain circle (via ORM). In order to do that I have to create a Polygon
(circle, linearring) in which orm will look. And Instead of using complicated calculations (and additional library). I thought I can use GeometricShapeFactory
from jts
lib I am already using. But because I am less than beginner what it comes to these things, all I wanted to ask, is whether or not the vertical ellipse generated by jts
is valid for my purposes or not ?
I am using google maps (as basemap).
My question:
Based on the fact that my ellipse is just wrong (considering given radius it should be a perfect circle – @whuber comment), how can I generate a proper Polygon
(circle, linearring) based on radius and center point ? (I am going to use it in hibernate-spatial
: (...).add(SpatialRestrictions.within(Mall.LOCATION, getCircle(centerPoint, 10)));
)
Best Answer
My first approach was giving me wrong results (wrong circle - a vertically elongated ellipse). It is not the right one because (to quote @whuber):
After @user30184 help/comment/suggestion, I think I got something, that can be called an answer. Snippet about conversion from geogrpahic to projected coordiante system is taken from here. This code gives me a perfect circle over
NYC
: