WorldWindEarth / worldwindjs

WorldWindJS is a community maintained fork of the WebWorldWind virtual globe SDK from NASA - an interactive 3D globe library featuring maps, imagery and terrain plus 2D map projections.
https://worldwind.earth/worldwindjs/
38 stars 9 forks source link

Add geographicToScreenPoint function and related logic (ported from Android) #31

Closed ComBatVision closed 5 years ago

ComBatVision commented 5 years ago

Description of the Change

Add geographicToScreenPoint function and related logic to determine pixel coordinates of a geographic location on the globe. This feature adds the reverse functionality of the pick function: it determines canvas coordinates of some geographic or cartesian point.

Why Should This Be In Core?

Enhances the utility of the SDK.

Benefits

Adds the ability to determine the pixel coordinates of a geographic location so you can can draw HTML popup or some HTML menu nearby this location.

Potential Drawbacks

Unknown.

Applicable Issues

Closes #28

ComBatVision commented 5 years ago

@emxsys We are using this code in our product to determine tactical graphics template, based on screen offset from some selected geo point.

For example we want to create template of polygon object in specified point, which should be 150x150 pixels in any zoom level and consists of three points. To do this, we convert selected geo point to screen point, than add some pixel offset to resulted screen point three times to have three template points for polygon and then get their coordinates back via pick.

Matrix function copy-pasted from Android implementation. I can create test case later this week. Now I am little bit busy.

emxsys commented 5 years ago

@Sufaev Thanks for that use case. It is a very enlightening example.

ComBatVision commented 5 years ago

The other use case - sometimes it is required to determine pixel coordinates of some location to draw HTML popup or some HTML menu nearby this location.

In our project we use this function to follow placemark by HTML SVG sector menu when rotating globe.

ComBatVision commented 5 years ago

@emxsys Could you give me a link for some unit test example. I am not JS developer to be ohnest :) I want to look how it looks like in current project to do similar.