joelgraff / freecad.trails

Trails is the Transportation Engineering workbench for FreeCAD
GNU Lesser General Public License v2.1
68 stars 12 forks source link

ADD support for Web Map Service (WMS) #84

Closed allanlaal closed 2 years ago

allanlaal commented 3 years ago

The OpenGIS® Web Map Service Interface Standard (WMS) provides a simple HTTP interface for requesting geo-registered map images from one or more distributed geospatial databases. A WMS request defines the geographic layer(s) and area of interest to be processed. The response to the request is one or more geo-registered map images (returned as JPEG, PNG, etc) that can be displayed in a browser application. The interface also supports the ability to specify whether the returned images should be transparent so that layers from multiple servers can be combined or not.

~ https://www.ogc.org/standards/wms

allanlaal commented 3 years ago

@joelgraff @DutchSailor you discussed merging GIS2BIM into trails, hows that coming along? can I help? :)

allanlaal commented 3 years ago

https://github.com/DutchSailor/FOSS-BIM-Experiments/issues/1

joelgraff commented 3 years ago

I haven't been looking at that at all, really. I've had a lot of other things distracting me from Trails these last few months and I'm focused on refactoring parts of it that aren't working well.

Implementing this sort of thing would certainly be welcome, but I know I don't really have the time to focus on it now myself.

allanlaal commented 3 years ago

GIS2BIM is the nearest thing I found for adding WMS support to FreeCAD

DutchSailor commented 2 years ago

I'm working on it currently, Probably next week it will be ready. I discussed with Hakan to add it to the trials workbench. So I will do a PR next week.

joelgraff commented 2 years ago

Ha! Ok. I had been working on incorporating it myself, but I haven't had a lot of time to devote to it. IT doesn't seem terribly complex, though.

DutchSailor commented 2 years ago

Several people with the same ideas is always good!! Below 2 screenshots of my work so far. One to define lat/lon location and the other to perform the WMS request, test the result and import it as image. Still working on a list with WMS-servers so that users can choose a server from a list. Files are in https://github.com/DutchSailor/FOSS-BIM-Experiments/tree/ac0b5270c4a04af346b5eeaeafb77f4f84b327a0/GIS2BIM

GIS2BIM WMS

GIS2BIM_map

HakanSeven12 commented 2 years ago

Nice progress 👍

joelgraff commented 2 years ago

Looks great!

DutchSailor commented 2 years ago

Import WMS update GIS2BIM_WMS

Geolocation expanded with multiple TMS-layers GIS2BIM_Geographic Location

Import TMS(Worldwide aerialphoto or map) GIS2BIM_TMS

HakanSeven12 commented 2 years ago

It looks amazing. If you are planning to import that feature to Trails, can you share this updates under Trails FreeCAD forum thread?

DutchSailor commented 2 years ago

The PR is merged! You can find the tool under 'Geo Import Tools' image

@allanlaal is it possible for you to test it? Just to make sure it's working.

HakanSeven12 commented 2 years ago

Here we go 🙂 Make an announcement about new features on forum topic and twitter.

HakanSeven12 commented 2 years ago

I made some import fixes. For windows users, FreeCAD don't have requests package at installation. Maybe you can use urllib or we can ask packager guys to add the request in conda and LP version of FreeCAD.

DutchSailor commented 2 years ago

That's a good point, the dependency on requests is removed now.

HakanSeven12 commented 2 years ago

It seems need another request fix.

11:20:06 Running the Python command 'Import TMS' failed: Traceback (most recent call last): File "C:\Users\hakan.seven\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\geomatics\geoimport_gui.py", line 172, in Activated import_tms.GIS_TMS_Dialog().exec_() File "C:\Users\hakan.seven\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\geomatics\geoimport\import_tms.py", line 71, in __init__ self.initUI() File "C:\Users\hakan.seven\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\geomatics\geoimport\import_tms.py", line 173, in initUI else: self.test_TMS() File "C:\Users\hakan.seven\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\geomatics\geoimport\import_tms.py", line 190, in test_TMS TMS = GIS2BIM.TMS_WMTSCombinedMapFromLatLonBbox(self.lat,self.lon,self.bboxWidth,self.bboxHeight,int(self.zoomLevel.text()),self.pixels,self.TMS_WMTS,self.ServerName) File "C:\Users\hakan.seven\AppData\Roaming\FreeCAD\Mod\freecad.trails\freecad\trails\geomatics\geoimport\GIS2BIM.py", line 299, in TMS_WMTSCombinedMapFromLatLonBbox TileImages.append(Image.open(requests.get(i, stream=True).raw))

DutchSailor commented 2 years ago

Oops, is resolved in new PR.

HakanSeven12 commented 2 years ago

Works for my system

OS: Windows 10 Version 2009 Word size of OS: 64-bit Word size of FreeCAD: 64-bit Version: 0.19.24291 (Git) Build type: Release Branch: releases/FreeCAD-0-19 Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac Python version: 3.8.6+ Qt version: 5.15.2 Coin version: 4.0.1 OCC version: 7.5.0 Locale: Turkish/Turkey (tr_TR)

HakanSeven12 commented 2 years ago

Also I moved GIS tools to a seperate toolbar. Its your play ground

GIS Tools

HakanSeven12 commented 2 years ago

I think if there is alredy a GeoOrigin object, your GIS-Sitedata object can use its coordinates. It uses UTM coordinate system and has a zone selector. So you can convert it coordinates to every system you want.