domlysz / BlenderGIS

Blender addons to make the bridge between Blender and geographic data
GNU General Public License v3.0
7.78k stars 1.35k forks source link

[enhancement] Move selection (offset to georef) #39

Closed s-leger closed 4 years ago

s-leger commented 8 years ago

Hi, I've some files with objects allready georeferenced, and would like to be able to append them to current scene.

In such scenario, linked objects are imported with current scene origin offset added.
It could be usefull to offset selection from current scene georeference. Maybe 2 small buttons (add and remove offset) could do the trick.

domlysz commented 8 years ago

Unfortunately, it's not possible to proceed like this because the real issue behind the offset trick is that Blender stores coordinates as single precision (float32) number which has about 7 significant digits of precision. On the other hand, geographic data must be represented as double precision (float64) number. Without the offset, coordinates will be rounded and we will lose accuracy.

A workaround for this use case will be to create an addon that just compute the deltas between the 2 origins offset and apply it to the appended objects.

s-leger commented 8 years ago

Your workarround is exactly what i'm looking for !

Basemap addon move objects and update scene dx dy, but i cant keep a consistant dx dy across multiple files. And setting dx dy by hand is not possible at this time (as far as i can tell). Osm also use the dx dy to import data. Maybe an option is to allow keeping a consistant dx dy as it when set, and import maps and data at center of window.

Also another usefull tool we should have is to create a plane with the background map as texture, so we can import more than 1 map at time to get better resolution.

I'm aware of the 32 bits precision probs, allready facing with it in late 97 under 3dsmax 3.

On the other hand, when an object pivot position is greater than 100k, only the final representation of offset+local coords is wrong, as internally the mesh vertices coords stay the same (as long as you don't apply location), whenever the object pivot is. So centering such object just improve the final precision, without any loose.

domlysz commented 8 years ago

Some tricks that may help

selection_001

so you can preset the origin before using the different tools and get something consistent by preventing basemaps updating the origin.

if you want to update the offset for a scene which already contains some objects you can use this snippet, it will move the objects according to the new offset values

import bpy

#import BlenderGIS modules depends on how the package is named
#if the addon is installed through github zip archive 
#then the name contains an illegal hyphen
#bellow an hacky workaround
import sys
sys.modules['BlenderGIS'] = __import__('BlenderGIS-master')

from BlenderGIS.geoscene import GeoScene

scn = bpy.context.scene
geoscn = GeoScene(scn)

#define here the new origin values
ox, oy = -55500, 5448000

dx = ox - geoscn.crsx
dy = oy - geoscn.crsy

geoscn.moveOriginPrj(dx, dy)

print(geoscn.getOriginPrj())

Also another usefull tool we should have is to create a plane with the background map as texture, so we can import more than 1 map at time to get better resolution.

yes this feature is already in my roadmap, high priority

On the other hand, when an object pivot position is greater than 100k, only the final representation of offset+local coords is wrong, as internally the mesh vertices coords stay the same (as long as you don't apply location), whenever the object pivot is. So centering such object just improve the final precision, without any loose.

Very interesting, this solution can help to deal with some situations where we need to release the offset, for example if we want to use the dxf exporter to get a correctly georef dxf file.

s-leger commented 8 years ago

Great, you made my dreams comes true !

Was working with Qgis but your add-on greatly improves the workflow. Maps and osm reprojected imports right in blender are invaluables !

I only encounter a crash issue while setting up GDAL wheel under windows 10 due to a wrong GDAL_DATA environnement variable.

The trick with > 100k pivot position and scene georef is to ensure the precision by taking account of the 7 significant digits of offset so you lower the risk to loose precision, even with larger offsets.

kikislater commented 8 years ago

Very interesting the manual offset, thanks Dominique. For DXF I make a translation in draftsight but I have to open drafsight, it's a little bit boring ... libopencad is new and in a few time released. There is also an implementation for Qgis with Gdal https://github.com/sandyre/libopencad

domlysz commented 8 years ago

an open source lib for dwg that's great ! It's so sad there is no strong open source cad app, librecad development seems so slow...

kikislater commented 8 years ago

Yes It's great. About what I heard, anytime sometimes want to create an opensource version, autodesk bring this to the court, the big company win and then project died ... This one shoudl be good because there is a ton of aim from different opensource communities !

s-leger commented 8 years ago

Fork it 1000 times so it take 100 years to autodesk to bring everyone to the court.

kikislater commented 8 years ago

:+1: Interesting ^_^

domlysz commented 8 years ago

todo list for fixing this issue:

s-leger commented 8 years ago

Reference links to link/append. http://blender.stackexchange.com/questions/23926/how-to-show-open-dialog-box-that-can-navigate-to-blender-datablocks

https://www.blender.org/api/blender_python_api_2_77_release/bpy.types.BlendDataLibraries.html

domlysz commented 8 years ago

now origin location is editable in geoscene panel

selection_002

bvgnt commented 8 years ago

I confirm as an architect that i systematicaly choose a point near my project and relocate all plans with wich i work. Here is the workflow i use.

Seems your not far from it, would be cool to get this rectangle (or any other shape) perimeter wich could then crop all imported data a bit like in Qgis. By the way nice job. you plugin is really impressive.