Wicket icon indicating copy to clipboard operation
Wicket copied to clipboard

Distinguish rectangles from polygons

Open BHare1985 opened this issue 8 years ago • 3 comments

I understand that WKT doesn't distinguish between a rectangle and a polygon, but google maps and possible other mapping libraries may.

Google maps for example has a rectangle object which differs, for example, allowing resizing the sides of the rectangle (2 vertices simultaneously) rather than single vertices like a polygon.

I would like to see an enhancement that can recognize rectangles vs polygons when going from WKT to gmap object

BHare1985 avatar May 04 '16 15:05 BHare1985

Wicket can already read google.maps.Rectangle instances:

https://github.com/arthur-e/Wicket/blob/master/wicket-gmap3.js#L483

And it can create google.maps.Rectangle instances:

https://github.com/arthur-e/Wicket/blob/master/wicket-gmap3.js#L128 https://github.com/arthur-e/Wicket/blob/master/wicket-gmap3.js#L193

If this doesn't work in practice (I don't think we have tests for it), please let me know.

arthur-e avatar May 04 '16 16:05 arthur-e

Confirmed this not working.

I am reading in POLYGON ((-81.37298583984375 40.989228176893796, -81.269989013671875 40.989228176893796, -81.269989013671875 40.928040105332393, -81.37298583984375 40.928040105332393, -81.37298583984375 40.989228176893796)) which was created using google maps retangle tool. When google maps loads it, its loaded as a polygon instead of a rectangle.

Also confirmed using http://arthur-e.github.io/Wicket/sandbox-gmaps3.html simply make a rectangle, take the WKT, clear map and map it. It becomes a polygon (each vertex moves on it's own)

BHare1985 avatar May 04 '16 17:05 BHare1985

I can confirm that it's worked fine, but firstly you should explicit set this value {WktInstance}.IsRectangle = true; before invoking toObject() method on Wkt instance. Then it will return google.maps.Rectangle object.

Here is source code for this property (default is false): https://github.com/arthur-e/Wicket/blob/9292bf47530065233d22c2247ab2a2a3e1c7bffa/wicket-gmap3.js#L35-L40

Expelz avatar Feb 10 '21 10:02 Expelz