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

Vector layer conversion #33

Merged
merged 2 commits into from Sep 18, 2014
Merged

Vector layer conversion #33

merged 2 commits into from Sep 18, 2014

Conversation

gberaudo
Copy link
Member

Core converters to be used by the vector synchronizer. #4 / #11

It handles:

  • all shapes;
  • fill and stroke colours;
  • outline width.

Dashes are not handled in general though some experimental code exists for lines.

It is now ready for merging though some issues remain:

Updated to reflect new state.
Old demo at http://dev.camptocamp.com/files/gberaudo/vectors/examples/vectors.html


/**
* Convert a 2D or 3D OpenLayers coordinate to Cesium.
* @param {!ol.coordinate} coordinate Ol3 coordinate
Copy link
Member

Choose a reason for hiding this comment

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

ol.coordinate -> ol.Coordinate

Copy link
Member

Choose a reason for hiding this comment

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

We usually end @param descriptions with a dot.

Copy link
Member

Choose a reason for hiding this comment

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

"Convert a 2D or 3D OpenLayers coordinate to Cesium." -> "Convert a 2D or 3D EPSG:4326 OpenLayers coordinate to a Cesium Cartesian3."

@ahocevar ahocevar modified the milestone: FEATURES Aug 25, 2014
* @param {!ol.geom.geometry} olGeometry Ol3 circle geometry
* @param {!ol.projectionLike} projection
* @param {!ol.style} olStyle
* @return {Cesium.Geometry|Array.<Cesium.Geometry>} geometries
Copy link
Member

Choose a reason for hiding this comment

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

Functions are easier to use when they always return values of the same type. In that case it should probably be Array.<Cesium.Geometry>.

* @api
*/
olcs.core.GL_ALIASED_LINE_WIDTH_RANGE;
//goog.exportProperty();
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this.

@elemoine
Copy link
Member

elemoine commented Sep 5, 2014

This is ton of work. Thanks. I still have some comments. But it's good to go to me when they are addressed.

@gberaudo
Copy link
Member Author

@ahocevar , examples including vectors.html can now be executed with compiled ol3cesium.js.
Just do a make dist and launch a server in dist directory.

This PR depends on the merge of two ol3 PRs: openlayers/openlayers#2703 and openlayers/openlayers#2696 . Please have a look to these PRs.
It would also benefit from a proper way of handling events and non-API base classes exports. openlayers/openlayers#2615 (comment)

It would be really great if everyone could test now and report issues so that we can discuss proper solutions and have time to address them.

As a side note, KML/geojson drag&drop on the ol3 map is enabled but not working.
It would also be great if someone knowledgeable about it could have a look.

@ahocevar
Copy link
Member

Thanks for the work on this. I did a bit more testing, and I found 2 issues:

  • When calling olcs.OLCesium#setEnabled(true) before a vector source has finished loading, no vector features will be displayed on the Cesium globe.
  • Performance for many features (I tested with the countries.json file from the ol3 examples) is surprisingly bad. Shouldn't Cesium be passed the simplified geometries that OpenLayers uses for rendering, instead of the original geometries?

It would also be good if @klokan could give this a review.

@gberaudo
Copy link
Member Author

Hi Andreas, thank you for testing.

It seems the lags comes from the text style of polygons, please comment
the 'text' in vector.js and you will see it is much faster.
You may also need to close the debugger window as it severely slows down
Cesium.

I am also able to load the countries geojson but not the 110m version.
The profiler seems to blame ol3. Could you confirm?

@gberaudo
Copy link
Member Author

Rebased on master following the merge of #42.

This PR is blocked by the still unmerged ol3 PRs.

They are quiet simple and necessary to get working:

  • compiled mode (no more crash on circle reprojection);
  • loading of non-cached icons.

I will have little time next week; we need to move on.

goog.events.unlisten(image, 'load', listener, this);
reallyCreateBillboard();
};
goog.events.listen(image, 'load', listener, this);
Copy link
Member

Choose a reason for hiding this comment

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

The function parameters are actually: goog.events.listen(src, type, listener, opt_capt, opt_handler) -- you are passing this as a boolean determining the capture phase. It would also be better to use goog.events.listenOnce in this case instead of unlistening the event after the first occurrence.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for spotting the error.

I was not using listenOnce because I wanted to ensure the image has been
loaded correctly. However, getting a 'load' event may perhaps be enough.

@petrsloup
Copy link
Member

Please make sure that make lint does not return any errors before merging this PR (many of these errors were merged as part of #42).

@elemoine elemoine added this to the FEATURES milestone Sep 16, 2014
@elemoine
Copy link
Member

What happens if you pass to Cesium an icon that is not already loaded?

@gberaudo
Copy link
Member Author

The icon will stay invisible for ever.
It is currently what you get when you force the browser to empty is
cache with ctrl+maj+r.

@gberaudo
Copy link
Member Author

Rebased on master.
Added a 3D polyline.

Please merge.

reallyCreateBillboard();
};

goog.events.listenOnce(image, 'load', listener, false, this);
Copy link
Member

Choose a reason for hiding this comment

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

The last two parameters are actually not needed here.

@petrsloup
Copy link
Member

Minor comments, otherwise LGTM.

Fixes invisible icon in Cesium when image in not in the browser cache.
It is inside the green square-like geometry.

Note that:
- 3D polygons or circles are not handled by Cesium;
- enabling depth test is necessary to prevent seeing a primitive through
  terrain.
@gberaudo
Copy link
Member Author

Thanks @petrsloup for the good review.

gberaudo added a commit that referenced this pull request Sep 18, 2014
@gberaudo gberaudo merged commit b7cceb7 into openlayers:master Sep 18, 2014
@gberaudo gberaudo deleted the vectors branch September 24, 2014 14:56
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.

None yet

4 participants