Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CircularString support #117

Open
c-martinez opened this issue Oct 27, 2017 · 2 comments
Open

CircularString support #117

c-martinez opened this issue Oct 27, 2017 · 2 comments
Labels

Comments

@c-martinez
Copy link

As far as I can see, circularstring objects are not yet supported. Are there any plans to support this and other curve types?

@arthur-e
Copy link
Owner

I have no plans to add this feature but welcome any pull requests that include it.

@ffflabs
Copy link
Contributor

ffflabs commented Feb 26, 2018

Circular strings are not supported on GeoJSON spec. Therefore, any implementation would require to transform such curves to an approximated linear geometry of an arbitrary presicion (see the implementation for google.maps.Circle)

Wicket/wicket-gmap3.js

Lines 415 to 444 in ab38c17

if (obj.constructor === google.maps.Circle) {
var point = obj.getCenter();
var radius = obj.getRadius();
verts = [];
var d2r = Math.PI / 180; // degrees to radians
var r2d = 180 / Math.PI; // radians to degrees
radius = radius / 1609; // meters to miles
var earthsradius = 3963; // 3963 is the radius of the earth in miles
var num_seg = 32; // number of segments used to approximate a circle
var rlat = (radius / earthsradius) * r2d;
var rlng = rlat / Math.cos(point.lat() * d2r);
for (var n = 0; n <= num_seg; n++) {
var theta = Math.PI * (n / (num_seg / 2));
lng = point.lng() + (rlng * Math.cos(theta)); // center a + radius x * cos(theta)
lat = point.lat() + (rlat * Math.sin(theta)); // center b + radius y * sin(theta)
verts.push({
x: lng,
y: lat
});
}
response = {
type: 'polygon',
components: [verts]
};
return response;
}

it would be overkill to implement this processing in the frontend, as the conversion from circularstrings can be already done in the backend. For example in PostGIS:

SELECT ST_AsText(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(-67 -40,-73 -40,-67 -40)')))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants