NASAWorldWind / WebWorldWind

The NASA WorldWind Javascript SDK (WebWW) includes the library and examples for creating geo-browser web applications and for embedding a 3D globe in HTML5 web pages.
898 stars 384 forks source link

Region picking rectangle is inverted #111

Open jaybarra opened 7 years ago

jaybarra commented 7 years ago

Using screen coordinates for the canvas in a worldWindow will not return any visible objects.

var clientRect = this.worldWindow.canvas.getBoundingClientRect();
var region = new WorldWind.Rectangle(
  clientRect.left, 
  clientRect.top,
  clientRect.width, 
  clientRect.height);

var pickedObjList = this.worldWindow.pickShapesInRegion(region);
jaybarra commented 7 years ago

Similarly attempting to get all shapes by using the canvas based coordinates also returns an empty pick list.

var clientRect = this.worldWindow.canvas.getBoundingClientRect(),
  canvasCoords = this.worldWindow.canvasCoordinates(clientRect.left, clientRect.top),
  region = new WorldWind.Rectangle(
    canvasCoords[0], canvasCoords[1],
    clientRect.width, clientRect.height);

 var pickList = this.worldWindow.pickShapesInRegion(region);  
pdavidc commented 7 years ago

Jay, It's unlikely that pickShapesInRegion is entirely broken as you've suggested in this issue. In particular, the example PickAllShapesInRegion is able to use pickShapesInRegion to select placemark objects. Would you please compare your code with the PickAllShapesInRegion example, looking for differences in the method and the shapes involved?

jaybarra commented 7 years ago

Dave, I was able to get it to work but it is not consistent. I do not understand what the rectangle represents; whether it is a rectangle on the screen or a rectangle projected onto the globe.

In the example cannot get the circle to be picked if I give it a rectangle containing the entire canvas. If I rubberband a selection area around the circle I can get the circle to be selected only if I start the region in within portions of the circle.

pickShapesInRegionTest.zip

pdavidc commented 7 years ago

Jay, Thanks for doing some digging. Based on your most recent test it does sound like there's an issue in pickShapesInRegion. We'll investigate from here.

pdavidc commented 6 years ago

We've found that WorldWindow.pickShapesInRegion interprets its rectangle as originating from its lower-left corner, whereas the application is expecting the upper-left corner.

ComBatVision commented 5 years ago

I can also confirm that picking of SurfacePolyline by pickShapesInRegion returns all shapes which has bounding box intersected with specified region even if the line itself does not cross the region.

Is it a feature or a bug? If you place surface shape with coordinated -90 to 90 and -180 to 180 than it will be selected by any reqion located inside of it.