-
Notifications
You must be signed in to change notification settings - Fork 227
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
Fix issue of exporting to google map multiple polygon #127
Conversation
songjiahong
commented
May 6, 2018
- Fix the algorithm of checking whether a polygon is clockwise
- Add all vertexes including the last overlapped one to the google map polygon
It looks like several tests are failing. Can you check out the Travis CI build details? In particular, the first Google Maps 3 test that fails:
It looks like maybe the first vertex is not being repeated (to close the ring)? |
Not feeling good today, I will check these tomorrow. Looks like the tests should be updated. |
wicket-gmap3.js
Outdated
// Orient inner rings correctly | ||
if (polygonIsClockwise(c[j]) && this.type == 'polygon') { | ||
verts.reverse(); | ||
if (j === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the logic of Google polygon, it doesn't require that the outer loop has be to counter-clockwise, the only requirement for polygon with hole is that the orientation of outer one should be different from inner ones.
@@ -336,19 +339,8 @@ | |||
return false; | |||
} | |||
|
|||
if (l === 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same logic for more than 1 paths. So I remove the 2 paths check.
areas = obj.getPaths().getArray().map(function (k) { | ||
return sign(k) / Math.abs(sign(k)); // Unit normalization (outputs 1 or -1) | ||
return sign(k) > 0 ? 1 : -1; // Unit normalization (outputs 1 or -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to avoid calculating of sign twice here
@@ -380,22 +371,6 @@ | |||
x: tmp.getAt(0).lng(), | |||
y: tmp.getAt(0).lat() | |||
}); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm not quite sure about the change, need your input here.
Does the components internally require all rings have the same orientation (clockwise or counter-clockwise)? If not, then maybe we don't need to reverse the inner rings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wicket doesn't care about the orientation of rings but the WKT standard requires that inner rings are reversed with respect to outer rings. For example, if the outer ring is oriented clockwise, then any inner rings should be oriented counter-clockwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this through and update the multiple polygon check
Thanks for checking the tests @songjiahong. Let me know what you've decided about inner ring orientation, then I'll confirm the pull request. |
All good now |
Great! Thanks so much. |