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

PolygonGraphics.hierarchy #2353

Merged
merged 14 commits into from
Jan 7, 2015
Merged

PolygonGraphics.hierarchy #2353

merged 14 commits into from
Jan 7, 2015

Conversation

mramato
Copy link
Contributor

@mramato mramato commented Dec 29, 2014

This can wait until after 1.6 instead of rushing it into master; I'll probably pull it into the implicit-properties branch first; to aid with other efforts.

  • Added PolygonHierarchy to Core to make defining polygons with holes clearer.
  • PolygonGraphics.positions was deprecated and replaced with PolygonGraphics.hierarchy, which evaluates to a PolygonHierarchy instead of an array of positions.
  • GeoJsonDataSource now supports polygons with holes.
  • ConstantProperty can now hold any value; previously it was limited to values that implemented equals and clones functions, as well as a few special cases.
  • CZML does not yet have support for holes and is still creating an array of positions instead of a PolygonHierarchy, which is still supported during the deprecation period. I'm still trying to determine the best way to do holes in CZML (which will most likely be a separate pull request unless anyone has any objections).
  • PolygonGraphics.positions created by GeoJSONDataSource now evaluate to a PolygonHierarchy object instead of an array of positions. This one is technically a breaking change I could probably jump through some additional hoops to avoid this if we think it's important; but it's an easy fix for anyone it may affect.

The overall goal is to move exclusively to the hierarchy property for PolygonGraphics and have it always evaluate to a PolygonHierarchy object. This simplifies the API for end users.

@bagnell Some of the GeoJSON files we test with look worse when using holes. I think it may be a big on our end; I'll see if I can pull together some examples for you to look at.

Used mostly for documentation, but can be instantiated with positions and holes.

Also deprecate `PolygonGraphics.positions` and add `PolygonGraphics.hierarchy` to replace it.
Update CHANGES.
Clean up some doc.
Make CzmlDataSource use `hierarchy` instead of `positions` (CZML still doesn't support holes).
@GatorScott
Copy link

Consider changing names so that rings can interpreted as holes or islands depending on position in hierarchy.
positions => outerRing
holes => innerRIngs

@mramato mramato changed the title PolygonGraphics.hiearchy PolygonGraphics.hierarchy Dec 29, 2014
@mramato
Copy link
Contributor Author

mramato commented Dec 29, 2014

Consider changing names so that rings can interpreted as holes or islands depending on position in hierarchy.
positions => outerRing
holes => innerRIngs

I'm not against this change, since it seems to be fairly standard terminology. However, we already use positions/holes for the lower level and public PolygonGeometry (not sure if we use it elsewhere as well). So if we we make this change, we'll also have to deprecate the existing behavior and change it to. @pjcozzi or @bagnell what do you think? If everyone is okay with the changes, I can update this branch to match.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 5, 2015

I think this is fine, but I suggest we also keep positions, which is consistent with the rest of Cesium, for polygons that do not have any holes.

@mramato
Copy link
Contributor Author

mramato commented Jan 5, 2015

The problem with keeping both is that it makes the API harder to use. We get away with this for PolygonGeometry because it's set via constructor only, you can't ever read the values back. For PolygonGraphics, it's set and get. If we allow for both positions and hierarchy to exist; then that means anywhere that needs to know the polygon definition needs to check two properties (and also be consistent in how they follow the rules for checking it, i.e. if they are both set use hierarchy instead of positions). What we can do is allow you to set hierarchy to a list of positions as well as an hierarchy (hierarchy.getValue would always return a PolygonHiearchy instance, but setting could go either way, which is what this branch does now).

I think we need to be careful about making incremental changes here and creating churn. If you want, I can close this PR and merge this branch into implicit properties and just have them all come in together (when it is ready); this way we can see the big picture rather than trying to make tough api decisions now.

@mramato
Copy link
Contributor Author

mramato commented Jan 7, 2015

@pjcozzi can I get a ruling here; I'd like to get this into master because several branches depend on it. I'll go a long with whatever you want; we have bigger fish to fry. Just let me know.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 7, 2015

I rather not making this renaming decision in haste when we have much bigger things on the radar. Let's leave it as is. We can revisit later if needed.

@bagnell can you review this?

@@ -532,12 +540,17 @@ define([
}

var options = this._options;
var positions = Property.getValueOrUndefined(polygon.positions, time, options.polygonHierarchy.positions);
if (!defined(positions)) {
var hierarchy = Property.getValueOrUndefined(polygon.hierarchy, time, this._scrach);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to assign to _scrach too? Its always undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually not needed at all. So I deleted the variable and parameter. Thanks. This is ready.

@bagnell
Copy link
Contributor

bagnell commented Jan 7, 2015

@mramato Just that one comment. The rest looks good.

bagnell added a commit that referenced this pull request Jan 7, 2015
@bagnell bagnell merged commit 032b141 into master Jan 7, 2015
@bagnell bagnell deleted the polygongraphics-holes branch January 7, 2015 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants