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

Deconstructing supports circle, point, latlng & returns WKT string #38

Merged
merged 1 commit into from Mar 18, 2014

Conversation

@amenadiel
Copy link
Contributor

amenadiel commented Mar 17, 2014

This feature adds support for google.maps.LatLng, google.maps.Point and google.maps.Circle objects to the Wkt.Wkt.prototype.deconstruct method. LatLng and Point result in a WKT Point, while Circle deconstruction returns a WKT Polygon made of 32 segments. (In concordance with PostGIS treatment of circle when using ST_Buffer).

Additionally, the deconstruction method will now return also a WKT key containing the WKT representation of the deconstructed element.

To test:

var Wicket =new Wkt.Wkt()
var NewCircle = new google.maps.Circle({radius:300, center: new google.maps.LatLng(37.75, -122.4) });
Wicket.deconstruct(NewCircle);

should return

Object {type: "polygon", components: Array[1], WKT: "POLYGON((-122.39659075856113 37.75,-122.3966562661…7942 37.7494741044496,-122.39659075856113 37.75))"}

Whereas

Wicket.deconstruct(NewCircle.getCenter());

should return

Object {type: "point", components: Array[1], WKT: "POINT(-122.4 37.75)"}
arthur-e added a commit that referenced this pull request Mar 18, 2014
Deconstructing supports circle, point, latlng & returns WKT string in Google Maps API extension
@arthur-e arthur-e merged commit 6204a9c into arthur-e:master Mar 18, 2014
@arthur-e

This comment has been minimized.

Copy link
Owner

arthur-e commented Mar 18, 2014

Neat, thanks!

@amenadiel

This comment has been minimized.

Copy link
Contributor Author

amenadiel commented Mar 19, 2014

@arthur-e there's a bug in line 287 of wicket-gmaps3.js

It says

wktverts.push(tpm.lng() + ' ' + tmp.lat());

it should say

wktverts.push(tmp.lng() + ' ' + tmp.lat());
@arthur-e

This comment has been minimized.

Copy link
Owner

arthur-e commented Mar 20, 2014

Thanks; in addition, it seems that the Google Maps API-related Jasmine tests are failing now? It seems that google.maps.geometry is not available at the time that it is accessed. I'm looking into this.

@arthur-e

This comment has been minimized.

Copy link
Owner

arthur-e commented Mar 20, 2014

Okay, it looks like that problem was needing to explicitly request that the geometry library be loaded i.e.
<script src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false" type="text/javascript"></script>

@arthur-e

This comment has been minimized.

Copy link
Owner

arthur-e commented Mar 21, 2014

A lot of unit tests are still failing. I think there is some confusion about the deconstruct() method. I noticed you changed the returned value of this method, but the deconstruct() method isn't supposed to be called directly. Rather, you would call fromObject() on the Wkt.Wkt() instance e.g.

var wkt = new Wkt.Wkt();
wkt.fromObject(new google.maps.Marker({...}));
@arthur-e

This comment has been minimized.

Copy link
Owner

arthur-e commented Mar 21, 2014

Okay, fixed all the test cases except the holey MultiPolygon case: "Standard WKT Test Cases: Converting objects into WKT strings: should convert an Array of Polygon instances, some with holes, into a MULTIPOLYGON string with the same." I think this was already broken, so we're good now. Please run the tests before issuing a Pull Request next time! (=D)

@amenadiel amenadiel referenced this pull request Apr 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.