domlysz / BlenderGIS

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

Large area mesh tilling #885

Open samstommy opened 5 months ago

samstommy commented 5 months ago

Loading a big area only tiles the textures of higher quality into one, when loading the osm, is too big for it.

How could i get a big area loaded into small tiles/meshes lets say the usual size of when zoomed to 17 or 18?

Ive been trying to do small pieces however its all manual the fitting afterwords and most of the times i get overlaps because i calculated the latitude and longitude offsets wrong, not to mention that when loaded the osm theres some overflow of the paths/roads outside of the tiles.

How could it be achieved? Maybe a script that enables the call of the gis addon as a macro to do all that, fit the screen with the desired area and then tile to mesh? I dont find anything around for reference on custom gis scripts

samstommy commented 5 months ago

i have found a base script from @DEUCE1957 to kinda achieve it however zoom doesn't work and neither setting the lat and long on call, does anyone have an idea for this?

//////////////// Script /////////////////// import bpy import time

old_type = bpy.context.area.type

bpy.context.area.type = 'VIEW_3D' bpy.ops.view3d.map_start(src="BING", lay="SAT", grd="WM", dialog="MAP", lon=-40.24 , lat=10.81 , zoom=10)

time.sleep(1)

bpy.ops.view3d.map_cancel() bpy.context.area.type = old_type

print("DONE") ///////////////////////////////////////

samstommy commented 5 months ago

Im using linux editing the view3d_mapviewer.py at .config/blender/3.0/scripts/addons/BlenderGIS-master/operators
ive added a new trigger:

script excerpt at line 924 :

EXPORT

if event.type == 'E' and event.value == 'PRESS' or self.export_trigger == 'EXPORT':

i can now call properly the export, heres the script

import bpy import time

old_type = bpy.context.area.type

bpy.context.area.type = 'VIEW_3D' bpy.ops.view3d.map_start(src="BING", lay="SAT", grd="WM", dialog="MAP")

time.sleep(5)

export_trigger = "EXPORT"

if export_trigger == "EXPORT": bpy.ops.view3d.map_viewer(export_trigger=export_trigger)

print("DONE")

i get these errors:

if self.map.lockedZoom is not None: File "../blender-3.0.0-linux-x64/3.0/scripts/modules/bpy_types.py", line 734, in getattribute properties = StructRNA.path_resolve(self, "properties") ReferenceError: StructRNA of type VIEW3D_OT_map_viewer has been removed ERROR:BlenderGIS-master:Uncaught exception Traceback (most recent call last): File "../.config/blender/3.0/scripts/addons/BlenderGIS-master/operators/view3d_mapviewer.py", line 324, in drawZoomBox if self.zoomBoxMode and not self.zoomBoxDrag: File "../blender-3.0.0-linux-x64/3.0/scripts/modules/bpy_types.py", line 734, in getattribute properties = StructRNA.path_resolve(self, "properties") ReferenceError: StructRNA of type VIEW3D_OT_map_viewer has been removed

samstommy commented 5 months ago

using: zoom_amount: bpy.props.FloatProperty()

where is the correct placement for adding the zoom_amount value?

    if event.type in ['WHEELUPMOUSE', 'NUMPAD_PLUS'] or self.zoom_amount > 0:

        if event.value == 'PRESS' or self.zoom_amount > 0:

            if event.alt:
                # map scale up
                self.map.scale *= 10
                self.map.place()
                #Scale existing objects
                for obj in scn.objects:
                    obj.location /= 10
                    obj.scale /= 10

            elif event.ctrl:
                # view3d zoom up
                dst = context.region_data.view_distance
                context.region_data.view_distance -= dst * self.moveFactor
                if self.prefs.zoomToMouse:
                    mouseLoc = mouseTo3d(context, event.mouse_region_x, event.mouse_region_y)
                    viewLoc = context.region_data.view_location
                    deltaVect = (mouseLoc - viewLoc) * self.moveFactor
                    viewLoc += deltaVect
            else:
                # map zoom up
                if self.map.zoom < self.map.layer.zmax and self.map.zoom < self.map.tm.nbLevels-1:
                    self.map.zoom += 1
                    if self.map.lockedZoom is None:
                        resFactor = self.map.tm.getNextResFac(self.map.zoom)
                        if not self.prefs.zoomToMouse:
                            context.region_data.view_distance *= (resFactor * self.zoom_amount)
                        else:
                            #Progressibly zoom to cursor
                            dst = context.region_data.view_distance
                            dst2 = dst * resFactor
                            context.region_data.view_distance = dst2
                            mouseLoc = mouseTo3d(context, event.mouse_region_x, event.mouse_region_y)
                            viewLoc = context.region_data.view_location
                            moveFactor = (dst - dst2) / dst
                            deltaVect = (mouseLoc - viewLoc) * moveFactor
                            if self.prefs.lockOrigin:
                                viewLoc += deltaVect
                            else:
                                dx, dy, dz = deltaVect
                                if not self.prefs.lockObj and self.map.bkg is not None:
                                    self.map.bkg.location  -= deltaVect
                                self.map.moveOrigin(dx, dy, updObjLoc=self.updObjLoc * self.zoom_amount)
                    self.map.get()