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

Add reprojection example #531

Merged
merged 2 commits into from
Feb 16, 2016
Merged

Add reprojection example #531

merged 2 commits into from
Feb 16, 2016

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Feb 15, 2016

The projections are taken from spatialreference.org, with some that look best listed at the top. The capital cities of the world are taken from geonames.org.

There is a performance issue when a select box exists with a few thousand items, so, by default, only a few dozen projections are shown. The example can show all of the known projections by commenting out a line.

Fixed a bug in d3 points where the stroke would not appear. This depends on the order of the style keys in the style dictionary -- if stroke came after strokeColor, the stroke might not appear.

Fixed an issue in vgl points where if a transform added a z-value, they might not be rendered. This could be changed if we ever address issue #394.

Allow changing a widget's geographic position.

Added the ability to set the maximum bounds on a map after it is created.

When we exited the vglRenderer, we did not destroy the canvas object. This means that if you create and destroy vgl layers repeatedly, eventually you will exhaust a browser's available gl contexts (depending on the hardware this could be as few as four gl layers or as many as 16). Additionally, more cleanup is done to ensure that memory can be released in a timely fashion.

Also, in testing this by toggling between transforms, I've added a guard against invalid projections, so that a error is sent to the console and the state can be recovered. Before, if a bad projection was set, it was often impossible to reset it to a valid value.

When the tile layer is a minimum level that isn't 0 and we want to keep lower levels and we aren't wrapping, then we should keep the entire lower level. This has two benefits: reprojections can look decent just by setting a minimum level even if their bounds are odd, and padding with a non-zero minimum level still has something to show. This has one drawback: if you have a very high minimum level (such as 5 or above), too many tiles need to be kept in memory.

When we exited the vglRenderer, we did not destroy the canvas object.  This means that if you create and destroy vgl layers repeatedly, eventually you will exhaust a browser's available gl contexts (depending on the hardware this could be as few as four gl layers or as many as 16).  Additionally, more cleanup is done to ensure that memory can be released in a timely fashion.

Also, in testing this by toggling between transforms, I've added a guard against invalid projections, so that a error is sent to the console and the state can be recovered.  Before, if a bad projection was set, it was often impossible to reset it to a valid value.

Lastly, when the tile layer is a minimum level that isn't 0 and we want to keep lower levels and we aren't wrapping, then we should keep the entire lower level.  This has two benefits: reprojections can look decent just by setting a minimum level even if their bounds are odd, and padding with a non-zero minimum level still has something to show.  This has one drawback: if you have a very high minimum level (such as 5 or above), too many tiles need to be kept in memory.
The projections are taken from spatialreference.org, with some that look best listed at the top.  The capital cities of the world are taken from geonames.org.

There is a performance issue when a select box exists with a few thousand items, so, by default, only a few dozen projections are shown.  The example can show all of the known projections by commenting out a line.

Fixed a bug in d3 points where the stroke would not appear.  This depends on the order of the style keys in the style dictionary -- if stroke came after strokeColor, the stroke might not appear.

Fixed an issue in vgl points where if a transform added a z-value, they might not be rendered.  This could be changed if we ever address issue #394.

Allow changing a widget's geographic position.

Added the ability to set the maximum bounds on a map after it is created.
@aashish24
Copy link
Member

this is awesome @manthey!

}
position = geo.transform.transformCoordinates(
m_this.gcs(), m_this.layer().map().gcs(),
position, 3);
/* Some transforms modify the z-coordinate. If we started with all zero z
* coordinates, don't modify them. This could be changed if the
* z-coordinate space of the gl cube is scaled appropriately. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Does proj4 set z-coordinates or is that something we are doing internally? I didn't think proj4 was even aware of a third dimension.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, proj4 sometimes produces non-zero z-coordinates. This happens, for instance, in some of the projections using datums other than WGS84/NAD83, where there is a different ellipsoid.

@jbeezley
Copy link
Contributor

This LGTM, but I want to reprioritize #329 once it goes in. Having more complicated examples like this is awesome, but it makes testing them more important.

manthey added a commit that referenced this pull request Feb 16, 2016
@manthey manthey merged commit e3a9180 into master Feb 16, 2016
@manthey manthey deleted the reprojection-example branch February 16, 2016 16:41
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.

3 participants