uber / nebula.gl

A suite of 3D-enabled data editing overlays, suitable for deck.gl
https://nebula.gl/
Other
690 stars 166 forks source link

Translate Edit Mode on static shape #411

Open pthomas931 opened 4 years ago

pthomas931 commented 4 years ago

Describe the bug

Using the translate edit mode on a static shape alters the shape.

Possibly related #396

Actual Result

Shapes intended to be static are warped to match elongated latitude and longitudes. translateMode

Expected Result

Shapes are definable as static and translation does not alter the shape.

Reproduce Steps

Screenshots

See Gif provided in description

To Do List

kthyer commented 4 years ago

To add to this, if an option to the translate mode could be added to opt-in or out of shape altering to better match the globe, I feel that would be ideal.

supersonicclay commented 4 years ago

This is expected due to mercator projection. The shapes are not actually larger in terms of surface area on the globe. It is the same reason that Greenland looks much larger with mercator project than it actually is when viewing it on a globe.

This is closer to the true size of Greenland: greenland

Shapes appear larger the further from the equator it is.

pthomas931 commented 4 years ago

I understand the reason for the view change in the current implementation. This issue is pertaining to shapes that are intentionally made the shape they are and not necessarily used for surface area concepts.

Ex: Having a rectangular shape to preview a potential viewport. The 2D monitor intended to focus on this preview is not considering the shape's surface area.

Hopefully this makes more sense?

supersonicclay commented 4 years ago

We use turf.js for these geometric operations (in this case we call transformTranslate). Perhaps you can post an issue there with more specifics of what you're after, or if there's another transformation method that achieves what you're looking for.

kthyer commented 4 years ago

I was hoping there was an easy way to drag a rectangle in particular and have it retain its shape on the map much closer to behavior seen in this example if you draw a rectangle and move its position: https://geoman.io/leaflet-geoman

The use case I have is to take a screenshot of the map area but be able to adjust the position before snapping the photo. You could do this with the tools built in on an OS but I want it built into the app.

This example has some vertical extension of the rectangle but for my use case that is ok. The problem for my use case with Nebula is the slanting of the shape, if there is no known transform method through turf to do this then I may need to make my own.

IlyaIzr commented 2 years ago

If I'm understanding correctly @kthyer wanted a behaviour showed in a attached picture. That's possible in Nebula but not documented anywhere properly When using translation mode you need to pass options of .viewport and .screenSpace to mode config, that is being proccessed here. I passed folowing option to test it out, not sure you need all of them

{
        height: map.getCanvasContainer().offsetHeight,
        width: map.getCanvasContainer().offsetWidth,
        zoom: map.getZoom(),
        latitude: map.getCenter().lat,
        longitude: map.getCenter().lng,
        bearing: map.getBearing(),
        pitch: map.getPitch(),
      }

I used maplibre map, it's almost mapbox map image