def onImport(self): width = float(self.bboxWidth.text()) height = float(self.bboxHeight.text()) pixWidth = float(self.pixelwidth.text()) self.pixHeight = (pixWidth*height)/width pixHeight = self.pixHeight URL = self.request.text() X = float(self.X) Y = float(self.Y) dx = float(self.dx.text())*1000 dy = float(self.dy.text())*1000 fileLocationWMS = self.tempFolder + self.imageName.text() + '.jpg' Bbox = GIS2BIM.CreateBoundingBox(X,Y,width,height,2) result = GIS2BIM.WMSRequest(URL,Bbox,fileLocationWMS,self.pixelwidth.text(),int(self.pixHeight)) if self.cbGrayscale.checkState(): img = Image.open(fileLocationWMS) fileLocationWMS2 = self.tempFolder + self.imageName.text() + '_gray.jpg' gray_image = ImageOps.grayscale(img) gray_image.save(fileLocationWMS2) else: fileLocationWMS2 = fileLocationWMS ImageAerialPhoto = GIS2BIM_FreeCAD.ImportImage(fileLocationWMS2,width/float(self.scale.text()),height/float(self.scale.text()),1000, str(self.imageName.text()), dx,dy) ImageAerialPhoto.addProperty("App::PropertyString","WMSRequestURL") ImageAerialPhoto.WMSRequestURL = result[2] GIS2BIM_FreeCAD.CreateLayer("GIS_Raster") FreeCAD.activeDocument().getObject("GIS_Raster").addObject(FreeCAD.activeDocument().getObject(ImageAerialPhoto.Label)) FreeCAD.ActiveDocument.recompute() self.close()
def onTest(self): URL = self.request.text() width = float(self.bboxWidth.text()) height = float(self.bboxHeight.text()) fileLocationWMS = self.tempFolder + self.imageName.text() + '.jpg' pixWidth = float(self.pixelwidth.text()) self.pixHeight = int((pixWidth*height)/width) pixHeight = self.pixHeight Bbox = GIS2BIM.CreateBoundingBox(float(self.X),float(self.Y),width,height,2) GIS2BIM.WMSRequest(URL,Bbox,self.tempFileName,pixWidth,pixHeight) if self.cbGrayscale.checkState(): img = Image.open(fileLocationWMS) fileLocationWMS2 = self.tempFolder + self.imageName.text() + '_gray.jpg' gray_image = ImageOps.grayscale(img) gray_image.save(fileLocationWMS2) else: fileLocationWMS2 = fileLocationWMS print(fileLocationWMS2) picture = QPixmap(fileLocationWMS2) picture = picture.scaledToWidth(800) pictheight = picture.height() if pictheight > 600: scale = 600/pictheight pictheight = 600 pictwidth = 800*scale picture = picture.scaledToWidth(pictwidth) else: pictwidth = 800 picture = picture.scaledToWidth(pictwidth) self.pictlabel.setPixmap(picture) self.pictlabel.setGeometry(QtCore.QRect(40, 40, pictwidth-40, pictheight-40)) self.pictlabel.hide() self.pictlabel.show()
def onOk(self): # Find latest version of temp.txt which contains the chosen coordinates filenames = [] filestamps = [] for filename in os.listdir(self.tempFolderPath): if filename.endswith(".txt"): filenames.append(filename) i = os.path.getmtime(self.tempFolderPath + "/" + filename) filestamps.append( time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(i))) latest = max(filestamps) indexof = filestamps.index(latest) latestfile = filenames[indexof] filepathTempfileLATLONData = self.tempFolderPath + "/" + latestfile #most recent file tempFileCoordinates = open(filepathTempfileLATLONData, "r") CoordinatesString = tempFileCoordinates.read() tempFileCoordinates.close() strsplit = re.split("[(, )]", CoordinatesString) self.lat = strsplit[1] self.lon = strsplit[3] SiteObject = GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename) CRS_EPSG_SRID = SiteObject.CRS_EPSG_SRID = GIS2BIM_CRS.inputChars[ self.cboCRS.currentIndex()] SiteObject.WGS84_Longitude = self.lon SiteObject.WGS84_Latitude = self.lat SiteObject.Longitude = float(self.lon) SiteObject.Latitude = float(self.lat) Transformation = GIS2BIM.TransformCRS_epsg("4326", CRS_EPSG_SRID, self.lon, self.lat) SiteObject.CRS_x = float(Transformation[0]) SiteObject.CRS_y = float(Transformation[1]) SiteObject.BoundingboxWidth = float(self.bboxWidth.text()) SiteObject.BoundingboxHeight = float(self.bboxHeight.text()) SiteObject.CRS_EPSG_Description = GIS2BIM_CRS.getCRSdata(CRS_EPSG_SRID) #Set GeoOrigin if self.CBGeoOrigin.isChecked() is True: obj = geo_origin.get() obj.Origin = FreeCAD.Vector( float(Transformation[0]) * 1000, float(Transformation[1]) * 1000, 0) if self.CBAerialphoto.isChecked() is True: fileLocationTMS = self.tempFolderPath + 'ESRI_aerialphoto.jpg' TMS = GIS2BIM.TMS_WMTSCombinedMapFromLatLonBbox( float(self.lat), float(self.lon), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 17, 256, 0, "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png" ) TMS[0].save(fileLocationTMS) ImageMap = GIS2BIM_FreeCAD.ImportImage( fileLocationTMS, float(self.bboxWidth.text()), float(self.bboxHeight.text()), 1000, "ESRI aerialMap", 0, 0) GIS2BIM_FreeCAD.CreateLayer("GIS_Raster") FreeCAD.ActiveDocument.recompute() FreeCAD.activeDocument().getObject("GIS_Raster").addObject( FreeCAD.activeDocument().getObject(ImageMap.Label)) self.close()
def __init__(self): super(GIS_TMS_Dialog, self).__init__() #Get/set parameters for GIS self.sitename = "GIS-Sitedata" self.tempFolderName = "GIStemp/" self.X = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x) self.Y = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y) self.lat = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Latitude) self.lon = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Longitude) self.CRS = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_EPSG_SRID) self.CRSDescription = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_EPSG_Description) self.bboxWidthStart = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).BoundingboxWidth) self.bboxHeightStart = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).BoundingboxHeight) self.width = float(self.bboxWidthStart) self.height = float(self.bboxHeightStart) self.tempFolder = GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName) self.folderName = self.tempFolder self.tempFileName = self.tempFolder + "initialTMS.jpg" self.zoomL = 17 self.pixels = 256 self.TMS_WMTS = 0 #Set Style self.setStyleSheet("QWidget {background-color: rgb(68, 68, 68)} QPushButton { background-color: black } QGroupBox {border: 1px solid grey; }") #margin: 2px; #Download list of predefined TMS Requests category = "webserverRequests" service = "WMTS_TMS" data = GIS2BIM.GetWebServerDataService(category,service) TitleList = [] for i in data: TitleList.append(i["title"]) ServerRequestPrefix = [] for i in data: ServerRequestPrefix.append(i["serverrequestprefix"]) yx = sorted(zip(TitleList,ServerRequestPrefix)) self.TitleList = [x[0] for x in yx] self.ServerRequestPrefix = [x[1] for x in yx] #Widget Right Bottom Combined gridRB = QtWidgets.QGridLayout() gridRB.addWidget(self.webserverGroup(), 0, 0, QtCore.Qt.AlignTop) gridRB.addWidget(self.freeCADGroup(), 1, 0, QtCore.Qt.AlignTop) #Overall Grid grid = QtWidgets.QGridLayout() grid.addWidget(self.imageGroup(), 0, 0, 1, 2) grid.addWidget(self.locationGroup(), 3, 0, QtCore.Qt.AlignTop) grid.addLayout(gridRB, 3, 1) grid.addLayout(self.buttonGroup(),4,0,1,2) grid.setRowStretch(0,2) self.setLayout(grid) self.setWindowTitle("Load Raster Data with TMS(Tile Map Server)") self.resize(920, 910) self.onTest()
def onImport(self): width = float(self.bboxWidth.text()) height = float(self.bboxHeight.text()) if width > 1000 or height > 1000 and int(self.zoomLevel.text()) >17: dialog = QtWidgets.QMessageBox() dialog.setText("Boundingbox is larger then 1000 meters. Set zoomlevel lower then 18 to prevent extreem large imagefiles") dialog.setWindowTitle("Warning") dialog.exec_() else: test = "test" dx = float(self.dx.text())*1000 dy = float(self.dy.text())*1000 fileLocationTMS = self.tempFolder + self.imageName.text() + '.jpg' TMS = GIS2BIM.TMS_WMTSCombinedMapFromLatLonBbox(float(self.lat),float(self.lon),float(self.bboxWidth.text()),float(self.bboxHeight.text()),int(self.zoomLevel.text()),self.pixels,self.TMS_WMTS,self.ServerName) TMS[0].save(fileLocationTMS) if self.cbGrayscale.checkState(): img = Image.open(fileLocationTMS) fileLocationTMS2 = self.tempFolder + self.imageName.text() + '_gray.jpg' gray_image = ImageOps.grayscale(img) gray_image.save(fileLocationTMS2) else: fileLocationTMS2 = fileLocationTMS ImageMap = GIS2BIM_FreeCAD.ImportImage(fileLocationTMS2,float(self.bboxWidth.text()),float(self.bboxHeight.text()),1000, str(self.imageName.text()), dx,dy) GIS2BIM_FreeCAD.CreateLayer("GIS_Raster") FreeCAD.ActiveDocument.recompute() FreeCAD.activeDocument().getObject("GIS_Raster").addObject(FreeCAD.activeDocument().getObject(ImageMap.Label)) FreeCAD.ActiveDocument.recompute() self.close()
def onTest(self): self.ServerName = self.request.text() TMS = GIS2BIM.TMS_WMTSCombinedMapFromLatLonBbox(float(self.lat),float(self.lon),float(self.bboxWidth.text()),float(self.bboxHeight.text()),int(self.zoomLevel.text()),self.pixels,self.TMS_WMTS,self.ServerName) fileLocationTMS = self.tempFolder + self.imageName.text() + '.jpg' TMS[0].save(fileLocationTMS) if self.cbGrayscale.checkState(): img = Image.open(fileLocationTMS) fileLocationTMS2 = self.tempFolder + self.imageName.text() + '_gray.jpg' gray_image = ImageOps.grayscale(img) gray_image.save(fileLocationTMS2) else: fileLocationTMS2 = fileLocationTMS picture = QPixmap(fileLocationTMS2) picture = picture.scaledToWidth(800) pictheight = picture.height() if pictheight > 600: scale = 600/pictheight pictheight = 600 pictwidth = 800*scale picture = picture.scaledToWidth(pictwidth) else: pictwidth = 800 picture = picture.scaledToWidth(pictwidth) self.pictlabel.setPixmap(picture) self.pictlabel.setGeometry(QtCore.QRect(40, 40, pictwidth-40, pictheight-40)) self.pictlabel.hide() self.pictlabel.show()
def onSearch(self): searchterm = self.search.text().split() self.lat = ( GIS2BIM.NominatimAPI(searchterm))[0] #Use Nominatim for geocoding self.lon = (GIS2BIM.NominatimAPI(searchterm))[1] if self.lat is None: dialog = QtWidgets.QMessageBox() dialog.setText("Address not found") dialog.setWindowTitle("Warning") dialog.exec_() else: JS = open(self.filepathJSSearch, "r") JS = JS.read() JS = JS.replace("51LAT", str(self.lat)) JS = JS.replace("4LONG", str(self.lon)) JS = JS.replace("FOLDERNAME", self.temptxtPath) self.webPage.runJavaScript(JS) # set view
def onTest(self): JS4 = open(self.filepathJSwfs, "r") JS4 = JS4.read() self.bboxString = GIS2BIM.CreateBoundingBox( float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x), float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 0) url = self.request.text() urlreq = url + self.bboxString urlpreview = urlreq + "&outputFormat=json&srsName=EPSG:4326" JS4 = JS4.replace("URLpreview", urlpreview) self.webPage.runJavaScript(JS4) # update wfs in mapview
def onImport(self): self.bboxString = GIS2BIM.CreateBoundingBox( float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x), float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 2) url = self.request.text() print(self.bboxString) print(url) xpathstr = self.xPathStr.text() closedValue = self.clsPolygon.isChecked() makeFaceValue = self.clsCreateFace.isChecked() drawStyle = str(self.linePattern.currentText()) Curves = GIS2BIM_FreeCAD.CurvesFromWFS(url, self.bboxString, xpathstr, -float(self.X), -float(self.Y), 1000, 3, closedValue, makeFaceValue, drawStyle, (0.7, 0.0, 0.0)) GIS2BIM_FreeCAD.CreateLayer(self.groupName.text()) FreeCAD.activeDocument().getObject( self.groupName.text()).addObjects(Curves) FreeCAD.ActiveDocument.recompute() self.close()
def __init__(self, parent=None): super(GIS_NL_Dialog, self).__init__(parent) self.sitename = "GIS-Sitedata" #Get/set parameters for GIS self.tempFolderName = "GIStemp/" self.X = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x) self.Y = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y) self.lat = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Latitude) self.lon = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Longitude) self.bboxWidthStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxWidth) self.bboxHeightStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxHeight) self.CRS = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_EPSG_SRID) self.CRSDescription = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).CRS_EPSG_Description) self.bboxString = GIS2BIM.CreateBoundingBox( float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x), float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y), float(self.bboxWidthStart), float(self.bboxHeightStart), 0) #Set Style self.setStyleSheet( "QWidget {background-color: rgb(68, 68, 68)} QPushButton { background-color: black } QGroupBox {border: 1px solid grey; }" ) #margin: 2px; #Download files self.URLUpdate = GIS2BIM.GetWebServerData( "HTMLLocationDataJSmapbboxupdate", "Other", "URL") #Javascript-URL for update boundingbox self.URLmap = GIS2BIM.GetWebServerData("HTMLwfs", "Other", "URL") self.filepathJSUpdate = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLUpdate, "map_bboxupdate.js") #Javascript-file for update boundingbox self.filepathBaseMap = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLmap, "basemapWFS.html") #Basemap from GIS2BIM Repository for preview self.filepathNewMap = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLmap, "mapWFS.html") #Edited Basemap with location and bbox #self.filepathBaseMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/basemapWFS.html" #self.filepathNewMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/mapWFS.html" self.tempFolderPath = GIS2BIM_FreeCAD.CreateTempFolder( self.tempFolderName) os.remove(self.filepathNewMap) BaseMap = open(self.filepathBaseMap, "r") BaseMapstr = BaseMap.read() Newstr = BaseMapstr.replace("51LAT", str(self.lat)) Newstr = Newstr.replace("4LONG", str(self.lon)) Newstr = Newstr.replace("WBBOX", self.bboxWidthStart) Newstr = Newstr.replace("HBBOX", self.bboxHeightStart) open(self.filepathNewMap, "x") f1 = open(self.filepathNewMap, "w") f1.write(Newstr) f1.close() #Overall Grid grid = QtWidgets.QGridLayout() grid.addWidget(self.webViewGroup(), 0, 0, 1, 2) grid.addWidget(self.locationGroup(), 3, 0) grid.addWidget(self.pdokGroup(), 3, 1) grid.addLayout(self.buttonGroup(), 4, 0, 1, 2) grid.setRowStretch(0, 2) self.setLayout(grid) self.setWindowTitle("PDOK: Load GIS-data in the Netherlands") self.resize(920, 910)
def onImport(self): Bbox = GIS2BIM.CreateBoundingBox(float(self.X), float(self.Y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 2) width = float(self.bboxWidth.text()) height = float(self.bboxHeight.text()) GIS2BIM_FreeCAD.CreateLayer("PDOK") fileLocationWMS = self.tempFolderPath + "wms.jpg" #Create Cadastral Parcels 2D if self.clsCad.isChecked() is True: GIS_2D_Cadastral_Parcel = GIS2BIM_FreeCAD.CreateLayer( "GIS_2D_Cadastral_Parcel") CadastralParcelCurves = GIS2BIM_FreeCAD.CurvesFromWFS( GIS2BIM_NL.NLPDOKCadastreCadastralParcels, Bbox, GIS2BIM_NL.NLPDOKxPathOpenGISposList, -float(self.X), -float(self.Y), 1000, 3, False, False, u"Dashdot", (0.0, 0.0, 0.0)) FreeCAD.activeDocument().getObject( "GIS_2D_Cadastral_Parcel").addObjects(CadastralParcelCurves) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("GIS_2D_Cadastral_Parcel")) #Create Building outline 2D if self.clsBld.isChecked() is True: GIS_2D_Building_Outline = GIS2BIM_FreeCAD.CreateLayer( "GIS_2D_Building_Outline") BAGCurves = GIS2BIM_FreeCAD.CurvesFromWFS( GIS2BIM_NL.NLPDOKBAGBuildingCountour, Bbox, GIS2BIM_NL.NLPDOKxPathOpenGISposList, -float(self.X), -float(self.Y), 1000, 3, True, True, u"Solid", (0.7, 0.0, 0.0)) FreeCAD.activeDocument().getObject( "GIS_2D_Building_Outline").addObjects(BAGCurves) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("GIS_2D_Building_Outline")) #Create 3D Building BAG 3D V2 if self.clsBAG3D.isChecked() is True: dx = -float(self.X) * 1000 dy = -float(self.Y) * 1000 bboxString = GIS2BIM.CreateBoundingBox( float( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x), float( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 0) jsonFileNames = GIS2BIM_NL.BAG3DDownload(Bbox, self.tempFolderPath) #Import JSON for jsonFile in jsonFileNames: meshes = GIS2BIM_FreeCAD.CityJSONImport( jsonFile, self.X, self.Y, 2, float(self.bboxWidth.text()), float(self.bboxHeight.text())) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("CityJSON")) # Import Aerialphoto in view if self.clsAerial.isChecked() is True: GIS_Raster = GIS2BIM_FreeCAD.CreateLayer("GIS_Raster") a = GIS2BIM.WMSRequest( GIS2BIM.GetWebServerData("NL_PDOK_Luchtfoto_2020_28992", "webserverRequests", "serverrequestprefix"), Bbox, fileLocationWMS, 3000, 3000) ImageAerialPhoto = GIS2BIM_FreeCAD.ImportImage( fileLocationWMS, width, height, 1000, "luchtfoto2020", 0, 0) ImageAerialPhoto.addProperty("App::PropertyString", "WMSRequestURL") ImageAerialPhoto.WMSRequestURL = a[2] FreeCAD.activeDocument().getObject("GIS_Raster").addObject( FreeCAD.activeDocument().getObject(ImageAerialPhoto.Label)) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("GIS_Raster")) #Create Textdata Cadastral Parcels if self.clsAnnotation.isChecked() is True: GIS_Annotation = GIS2BIM_FreeCAD.CreateLayer("GIS_Annotation") textDataCadastralParcels = GIS2BIM.DataFromWFS( GIS2BIM_NL.NLPDOKCadastreCadastralParcelsNummeraanduiding, Bbox, GIS2BIM_NL.NLPDOKxPathOpenGISPos, GIS2BIM_NL.xPathStringsCadastreTextAngle, -float(self.X), -float(self.Y), 1000, 3) textDataOpenbareRuimtenaam = GIS2BIM.DataFromWFS( GIS2BIM_NL.NLPDOKCadastreOpenbareruimtenaam, Bbox, GIS2BIM_NL.NLPDOKxPathOpenGISPos, GIS2BIM_NL.xPathStringsCadastreTextAngle, -float(self.X), -float(self.Y), 1000, 3) placeTextFreeCAD1 = GIS2BIM_FreeCAD.PlaceText( textDataCadastralParcels, 500, 0) placeTextFreeCAD2 = GIS2BIM_FreeCAD.PlaceText( textDataOpenbareRuimtenaam, 2000, 1) FreeCAD.activeDocument().getObject("GIS_Annotation").addObjects( placeTextFreeCAD1) FreeCAD.activeDocument().getObject("GIS_Annotation").addObjects( placeTextFreeCAD2) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("GIS_Annotation")) #Create Ruimtelijke plannen outline 2D if self.clsBouwvlak.isChecked() is True: GIS_2D_Ruimtelijke_Plannen = GIS2BIM_FreeCAD.CreateLayer( "GIS_2D_Ruimtelijke_Plannen") RuimtelijkePlannenBouwvlakCurves = GIS2BIM_FreeCAD.CurvesFromWFS( GIS2BIM_NL.NLRuimtelijkeplannenBouwvlak, Bbox, ".//{http://www.opengis.net/gml}posList", -float(self.X), -float(self.Y), 1000, 3, False, False, u"Solid", (0.0, 0.0, 1.0)) FreeCAD.activeDocument().getObject( "GIS_2D_Ruimtelijke_Plannen").addObjects( RuimtelijkePlannenBouwvlakCurves) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject( "GIS_2D_Ruimtelijke_Plannen")) #Create BGT 2D if self.clsBGT.isChecked() is True: timeout = 150 folderBGT = GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName + '/BGT') filepathZIP = folderBGT + '.zip' #Download BGT URL = GIS2BIM_NL.bgtDownloadURL(float(self.X), float(self.Y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), timeout) GIS2BIM.downloadUnzip(URL, filepathZIP, folderBGT) #Create Curves bgt_curves_faces = [ "bgt_begroeidterreindeel", "bgt_onbegroeidterreindeel", "bgt_ondersteunendwaterdeel", "bgt_ondersteunendwegdeel", "bgt_overbruggingsdeel", "bgt_overigbouwwerk", "bgt_waterdeel", "bgt_wegdeel" ] bgt_curves_faces_color = [(223 / 255, 230 / 255, 208 / 255), (223 / 255, 230 / 255, 208 / 255), (205 / 255, 230 / 255, 237 / 255), (226 / 255, 226 / 255, 226 / 255), (234 / 255, 234 / 255, 234 / 255), (220 / 255, 155 / 255, 140 / 255), (205 / 255, 230 / 255, 237 / 255), (234 / 255, 234 / 255, 234 / 255)] bgt_curves_lines = [ "bgt_functioneelgebied", "bgt_gebouwinstallatie", "bgt_kunstwerkdeel", "bgt_overbruggingsdeel", "bgt_overigbouwwerk", "bgt_overigescheiding", "bgt_scheiding", "bgt_spoor", "bgt_tunneldeel" ] xpath = './/{http://www.opengis.net/gml}posList' GIS2BIM_FreeCAD.CreateLayer("BGT") #Draw bgt_curves_lines for i in bgt_curves_lines: path = folderBGT + '/' + i + '.gml' tree = ET.parse(path) Curves = GIS2BIM_FreeCAD.CurvesFromGML( tree, xpath, -float(self.X), -float(self.Y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 1000, 0, 0, 0, "Solid", (0.7, 0.0, 0.0), (0.0, 0.0, 0.0)) GIS2BIM_FreeCAD.CreateLayer(i) FreeCAD.activeDocument().getObject(i).addObjects(Curves) FreeCAD.activeDocument().getObject("BGT").addObject( FreeCAD.activeDocument().getObject(i)) FreeCAD.ActiveDocument.recompute() for i, j in zip(bgt_curves_faces, bgt_curves_faces_color): path = folderBGT + '/' + i + '.gml' tree = ET.parse(path) Curves = GIS2BIM_FreeCAD.CurvesFromGML( tree, xpath, -float(self.X), -float(self.Y), float(self.bboxWidth.text()), float(self.bboxHeight.text()), 1000, 2, 1, 1, "Solid", (0.7, 0.0, 0.0), j) GIS2BIM_FreeCAD.CreateLayer(i) FreeCAD.activeDocument().getObject(i).addObjects(Curves) FreeCAD.activeDocument().getObject("BGT").addObject( FreeCAD.activeDocument().getObject(i)) FreeCAD.ActiveDocument.recompute() FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("BGT")) # Import bestemmingsplankaart if self.clsBestemmingsplan.isChecked() is True: GIS_Raster = GIS2BIM_FreeCAD.CreateLayer("GIS_Raster") a = GIS2BIM.WMSRequest( GIS2BIM.GetWebServerData( "NL_INSPIRE_Ruimtelijke_Plannen_Totaal_28992", "webserverRequests", "serverrequestprefix"), Bbox, fileLocationWMS, 3000, 3000) ImageAerialPhoto = GIS2BIM_FreeCAD.ImportImage( fileLocationWMS, width, height, 1000, "Ruimtelijke Plannen", 0, 0) ImageAerialPhoto.addProperty("App::PropertyString", "WMSRequestURL") ImageAerialPhoto.WMSRequestURL = a[2] FreeCAD.activeDocument().getObject("GIS_Raster").addObject( FreeCAD.activeDocument().getObject(ImageAerialPhoto.Label)) FreeCAD.activeDocument().getObject("PDOK").addObject( FreeCAD.activeDocument().getObject("GIS_Raster")) FreeCAD.ActiveDocument.recompute() self.close()
def __init__(self, parent=None): super(GISWFS_Dialog, self).__init__(parent) self.sitename = "GIS-Sitedata" dialog = QtWidgets.QMessageBox() dialog.setText( " Several limitations are 1) WFS 2.0.0 2) Server should support SRS 4326 3)For preview purposes server should support GeoJSON 4)Request for import works only with gml. Work in progress!" ) dialog.setWindowTitle("Warning: This is a Proof of Concept.") dialog.exec_() #Get/set parameters for GIS self.tempFolderName = "GIStemp/" self.X = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x) self.Y = str(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y) self.lat = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Latitude) self.lon = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).WGS84_Longitude) self.bboxWidthStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxWidth) self.bboxHeightStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxHeight) self.CRS = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_EPSG_SRID) self.CRSDescription = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).CRS_EPSG_Description) self.bboxString = GIS2BIM.CreateBoundingBox( float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_x), float(GIS2BIM_FreeCAD.ArchSiteCreateCheck(self.sitename).CRS_y), float(self.bboxWidthStart), float(self.bboxHeightStart), 0) #Set Style self.setStyleSheet( "QWidget {background-color: rgb(68, 68, 68)} QPushButton { background-color: black } QGroupBox {border: 1px solid grey; }" ) #margin: 2px; #Download files self.URLUpdate = GIS2BIM.GetWebServerData( "HTMLLocationDataJSmapbboxupdate", "Other", "URL") #Javascript-URL for update boundingbox self.URLwfs = GIS2BIM.GetWebServerData( "HTMLwfsJSwfsUpdate", "Other", "URL") #Javascript-URL for update wfs self.URLmap = GIS2BIM.GetWebServerData("HTMLwfs", "Other", "URL") self.filepathJSUpdate = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLUpdate, "map_bboxupdate.js") #Javascript-file for update boundingbox self.filepathJSwfs = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLwfs, "map_wfsupdate.js") #Javascript-file for update wfs self.filepathBaseMap = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLmap, "basemapWFS.html") #Basemap from GIS2BIM Repository for preview self.filepathNewMap = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLmap, "mapWFS.html") #Edited Basemap with location and bbox #self.filepathBaseMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/basemapWFS.html" #self.filepathNewMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/mapWFS.html" self.tempFolderPath = GIS2BIM_FreeCAD.CreateTempFolder( self.tempFolderName) os.remove(self.filepathNewMap) BaseMap = open(self.filepathBaseMap, "r") BaseMapstr = BaseMap.read() Newstr = BaseMapstr.replace("51LAT", str(self.lat)) Newstr = Newstr.replace("4LONG", str(self.lon)) Newstr = Newstr.replace("WBBOX", self.bboxWidthStart) Newstr = Newstr.replace("HBBOX", self.bboxHeightStart) open(self.filepathNewMap, "x") f1 = open(self.filepathNewMap, "w") f1.write(Newstr) f1.close() #Download list of predefined WFS Requests category = "webserverRequests" service = "WFS_curves" data = GIS2BIM.GetWebServerDataService(category, service) TitleList = [] for i in data: TitleList.append(i["title"]) ServerRequestPrefix = [] for i in data: ServerRequestPrefix.append(i["serverrequestprefix"]) yx = sorted(zip(TitleList, ServerRequestPrefix)) self.TitleList = [x[0] for x in yx] self.ServerRequestPrefix = [x[1] for x in yx] #Widget Right Bottom Combined gridRB = QtWidgets.QGridLayout() gridRB.addWidget(self.webserverGroup(), 0, 0, QtCore.Qt.AlignTop) gridRB.addWidget(self.freeCADGroup(), 1, 0, QtCore.Qt.AlignTop) #Overall Grid grid = QtWidgets.QGridLayout() grid.addWidget(self.webViewGroup(), 0, 0, 1, 2) grid.addWidget(self.locationGroup(), 3, 0, QtCore.Qt.AlignTop) grid.addLayout(gridRB, 3, 1) grid.addLayout(self.buttonGroup(), 4, 0, 1, 2) grid.setRowStretch(0, 2) self.setLayout(grid) self.setWindowTitle("Load 2D Vector Data with WFS(Web Feature Server)") self.resize(920, 910)
def __init__(self): super(GISLocation_Dialog, self).__init__() self.sitename = "GIS-Sitedata" self.tempFolderName = "GIStemp/" #Get/set parameters for GIS self.lat = GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).WGS84_Latitude self.lon = GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).WGS84_Longitude self.bboxWidthStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxWidth) self.bboxHeightStart = str( GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).BoundingboxHeight) self.CRS = GIS2BIM_FreeCAD.ArchSiteCreateCheck( self.sitename).CRS_EPSG_SRID #Create temp folders/files self.URLmap = GIS2BIM.GetWebServerData("HTMLLocationData", "Other", "URL") self.URLSearch = GIS2BIM.GetWebServerData( "HTMLLocationDataJSmapfilesearch", "Other", "URL") self.URLUpdate = GIS2BIM.GetWebServerData( "HTMLLocationDataJSmapbboxupdate", "Other", "URL") #self.filepathBaseMap = GIS2BIM.DownloadURL(GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName),self.URLmap,"basemap.html") self.filepathJSSearch = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLSearch, "map_filesearch.js") self.filepathJSUpdate = GIS2BIM.DownloadURL( GIS2BIM_FreeCAD.CreateTempFolder(self.tempFolderName), self.URLUpdate, "map_bboxupdate.js") self.filepathBaseMap = "C:/Users/mikev/OneDrive/Bureaublad/TEMP/GIStemp/basemapNewVersion.html" self.tempFolderPath = GIS2BIM_FreeCAD.CreateTempFolder( self.tempFolderName) self.filepathNewMap = self.tempFolderPath + "/map.html" self.temptxtPath = self.tempFolderPath + "/temp.txt" #Set Style self.setStyleSheet(GIS2BIM_GUI.StyleSheet) #margin: 2px for file in os.listdir(self.tempFolderPath): # Cleanup of txt-files if file.endswith(".txt"): self.filename = self.tempFolderPath + "/" + file os.remove(self.filename) #self.application = QApplication(sys.argv) #extend this to kill the webengineprocess #Overall Grid grid = QtWidgets.QGridLayout() grid.addWidget(self.webViewGroup(), 0, 0) grid.addWidget(self.locationGroup(), 1, 0, QtCore.Qt.AlignTop) grid.addLayout(self.buttonGroup(), 2, 0) grid.setRowStretch(0, 3) self.setLayout(grid) self.setWindowTitle("Set Geographic Location") self.resize(920, 900) #Download map.html from GIS2BIM Repository and set projectlocation os.remove(self.filepathNewMap) BaseMap = open(self.filepathBaseMap, "r") BaseMapstr = BaseMap.read() Newstr = BaseMapstr.replace("51LAT", self.lat) Newstr = Newstr.replace("4LONG", self.lon) Newstr = Newstr.replace("FOLDERNAME", self.temptxtPath) Newstr = Newstr.replace("WBBOX", self.bboxWidthStart) Newstr = Newstr.replace("HBBOX", self.bboxHeightStart) open(self.filepathNewMap, "x") f1 = open(self.filepathNewMap, "w") f1.write(Newstr) f1.close()