From 56d7a7f65418d1cbbf480462e24327ffc3e19517 Mon Sep 17 00:00:00 2001 From: Maarten Vroegindeweij <30430941+DutchSailor@users.noreply.github.com> Date: Mon, 7 Oct 2024 08:27:08 +0200 Subject: [PATCH] Update --- .../example/GIS2BIM/NL_0_geocoding test.py | 129 ++++++++++++++++++ .../example/GIS2BIM/NL_3_Cadaster.py | 10 +- .../example/GIS2BIM/NL_DownloadBasis.py | 40 +++++- 3 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 sandbox/Versie juni 2024/example/GIS2BIM/NL_0_geocoding test.py diff --git a/sandbox/Versie juni 2024/example/GIS2BIM/NL_0_geocoding test.py b/sandbox/Versie juni 2024/example/GIS2BIM/NL_0_geocoding test.py new file mode 100644 index 00000000..89be5c0e --- /dev/null +++ b/sandbox/Versie juni 2024/example/GIS2BIM/NL_0_geocoding test.py @@ -0,0 +1,129 @@ +from packages.GIS2BIM.GIS2BIM_NL import * + +test = NL_GetLocationData(NLPDOKServerURL,"Dordrecht","werf van schouten", "501") + +class NL_Geocoding: + def __init__(self): + self.servername = NLPDOKServerURL + self.bron = None + self.woonplaatscode = None + self.type = None + self.woonplaatsnaam = None + self.wijkcode = None + self.huis_nlt = None + self.openbareruimtetype = None + self.buurtnaam = None + self.gemeentecode = None + self.rdf_seealso = None + self.rdf_seealso = None + self.weergavenaam = None + self.straatnaam_verkort = None + self.id = None + self.gekoppeld_perceel = None + self.gemeentenaam = None + self.buurtcode = None + self.wijknaam = None + self.identificatie = None + self.openbareruimte_id = None + self.waterschapsnaam = None + self.provinciecode = None + self.postcode = None + self.provincienaam = None + self.centroide_ll = None + self.centroid_X = None + self.centroid_Y = None + self.nummeraanduiding_id = None + self.waterschapscode = None + self.adresseerbaarobject_id = None + self.huisnummer = None + self.provincieafkorting = None + self.centroide_rd = None + self.rdx = None + self.rdy = None + self.straatnaam = None + self.score = None + self.url = None + + def by_address(self, City: str, Streetname: str, Housenumber: str): + # Use PDOK location server to get X & Y data + PDOKServer = self.servername + SN = Streetname.replace(" ", "%20") + self.url = PDOKServer + City + "%20and%20" + SN + "%20and%20" + Housenumber + urlFile = urllib.request.urlopen(self.url) + jsonList = json.load(urlFile) + jsonList = jsonList["response"]["docs"] + jsonList1 = jsonList[0] + self.fill_param(jsonList1) + return self + + def by_rdx_rdy(self, rdx: float, rdy: float): + PDOKServer = "https://api.pdok.nl/bzk/locatieserver/search/v3_1/reverse?X=RDX&Y=RDY&rows=1" + PDOKServer = PDOKServer.replace("RDX", str(rdx)) + PDOKServer = PDOKServer.replace("RDY", str(rdy)) + urlFile = urllib.request.urlopen(PDOKServer) + jsonList = json.load(urlFile) + id = jsonList["response"]["docs"][0]["id"] + PDOKServer = self.servername + PDOKServer = PDOKServer + id + urlFile = urllib.request.urlopen(PDOKServer) + jsonList = json.load(urlFile) + jsonList = jsonList["response"]["docs"] + jsonList1 = jsonList[0] + self.fill_param(jsonList1) + self.url = PDOKServer + return self + def fill_param(self, resp): + jsonList1 = resp + RD = jsonList1['centroide_rd'] + RD = RD.replace("(", " ").replace(")", " ") + RD = RD.split() + RDx = float(RD[1]) + RDy = float(RD[2]) + LatLon = jsonList1['centroide_ll'] + LatLon = LatLon.replace("(", " ").replace(")", " ") + LatLon = LatLon.split() + Lat = float(LatLon[1]) + Lon = float(LatLon[2]) + self.bron = jsonList1['bron'] + self.woonplaatscode = jsonList1['woonplaatscode'] + self.type = jsonList1['type'] + self.woonplaatsnaam = jsonList1['woonplaatsnaam'] + self.wijkcode = jsonList1['wijkcode'] + self.huis_nlt = jsonList1['huis_nlt'] + self.openbareruimtetype = jsonList1['openbareruimtetype'] + self.buurtnaam = jsonList1['buurtnaam'] + self.gemeentecode = jsonList1['gemeentecode'] + self.rdf_seealso = jsonList1['rdf_seealso'] + self.weergavenaam = jsonList1['weergavenaam'] + self.straatnaam_verkort = jsonList1['straatnaam_verkort'] + self.id = jsonList1['id'] + self.gekoppeld_perceel = jsonList1['gekoppeld_perceel'] + self.gemeentenaam = jsonList1['gemeentenaam'] + self.buurtcode = jsonList1['buurtcode'] + self.wijknaam = jsonList1['wijknaam'] + self.identificatie = jsonList1['identificatie'] + self.openbareruimte_id = jsonList1['openbareruimte_id'] + self.waterschapsnaam = jsonList1['waterschapsnaam'] + self.provinciecode = jsonList1['provinciecode'] + self.postcode = jsonList1['postcode'] + self.provincienaam = jsonList1['provincienaam'] + self.centroide_ll = jsonList1['centroide_ll'] + self.lat = Lat + self.lon = Lon + self.nummeraanduiding_id = jsonList1['nummeraanduiding_id'] + self.waterschapscode = jsonList1['waterschapscode'] + self.adresseerbaarobject_id = jsonList1['adresseerbaarobject_id'] + self.huisnummer = jsonList1['huisnummer'] + self.provincieafkorting = jsonList1['provincieafkorting'] + self.centroide_rd = jsonList1['centroide_rd'] + self.rdx = RDx + self.rdy = RDy + self.straatnaam = jsonList1['straatnaam'] + self.score = jsonList1['score'] + return self + +geoc = NL_Geocoding().by_address("Dordrecht","werf van schouten", "501") +geoc2 = NL_Geocoding().by_rdx_rdy(194195.304, 465885.902) + +#print(geoc.rdx) +#print(geoc2.url) diff --git a/sandbox/Versie juni 2024/example/GIS2BIM/NL_3_Cadaster.py b/sandbox/Versie juni 2024/example/GIS2BIM/NL_3_Cadaster.py index 16a4b5c2..21de2492 100644 --- a/sandbox/Versie juni 2024/example/GIS2BIM/NL_3_Cadaster.py +++ b/sandbox/Versie juni 2024/example/GIS2BIM/NL_3_Cadaster.py @@ -1,9 +1,11 @@ from packages.GIS2BIM.GIS2BIM_NL import * +from packages.GIS2BIM.GIS2BIM import * from project.fileformat import * from exchange.GIS2BIM import * from geometry.mesh import MeshPB from library.material import * from abstract.image import * +#from GIS2BIM_single_file import * # Description # This script creates lines for the cadastral parcels and a mesh for a building footprint for any building in @@ -22,11 +24,11 @@ # BASE VALUES RdX = lst[0] RdY = lst[1] -Bbox = GIS2BIM.CreateBoundingBox(RdX, RdY, Bboxwidth, Bboxwidth, 0) +Bbox = CreateBoundingBox(RdX, RdY, Bboxwidth, Bboxwidth, 0) # Aerialphoto fileLocationWMS = tempfolder + "luchtfoto_2020_2.png" -a = GIS2BIM.WMSRequest(GIS2BIM.GetWebServerData("NL_PDOK_Luchtfoto_2020_28992", "webserverRequests", +a = WMSRequest(GetWebServerData("NL_PDOK_Luchtfoto_2020_28992", "webserverRequests", "serverrequestprefix"), Bbox, fileLocationWMS, 1500, 1500) @@ -34,14 +36,14 @@ # GISProject.objects.append(img) # KADASTRALE GRENZEN -curvesCadaster = GIS2BIM.PointsFromWFS(NLPDOKCadastreCadastralParcels, Bbox, NLPDOKxPathOpenGISposList, -RdX, -RdY, +curvesCadaster = PointsFromWFS(NLPDOKCadastreCadastralParcels, Bbox, NLPDOKxPathOpenGISposList, -RdX, -RdY, 1000, 2) # for i in WFSCurvesToBPCurvesLinePattern(curvesCadaster, Centerline): for i in WFSCurvesToBPCurves(curvesCadaster): GISProject.objects.append(i) # GEBOUWEN -curvesBAG = GIS2BIM.PointsFromWFS(NLPDOKBAGBuildingCountour, Bbox, NLPDOKxPathOpenGISposList, -RdX, -RdY, 1000, +curvesBAG = PointsFromWFS(NLPDOKBAGBuildingCountour, Bbox, NLPDOKxPathOpenGISposList, -RdX, -RdY, 1000, 2) BPCurvesBAG = WFSCurvesToBPCurves(curvesBAG) # for i in WFSCurvesToBPCurves(curvesBAG): diff --git a/sandbox/Versie juni 2024/example/GIS2BIM/NL_DownloadBasis.py b/sandbox/Versie juni 2024/example/GIS2BIM/NL_DownloadBasis.py index 4e298d90..e48bd9f4 100644 --- a/sandbox/Versie juni 2024/example/GIS2BIM/NL_DownloadBasis.py +++ b/sandbox/Versie juni 2024/example/GIS2BIM/NL_DownloadBasis.py @@ -6,6 +6,25 @@ from packages.GIS2BIM.GIS2BIM import * from project.fileformat import * from packages.GIS2BIM.GIS2BIM_NL_helpers import * + +import ssl + +#SETTINGS BASIS +GISProject = BuildingPy("test") +ProjectDrive = "E:/" +ProjectFolder = ProjectDrive + "GIS2BIM/" +City = "Lekkerkerk" +Street = "Voorstraat" +HouseNumber = "172" +ProjectName = City + "_" + Street + "_" + HouseNumber +lst = NL_GetLocationData(NLPDOKServerURL, City, Street, HouseNumber) +Bboxwidth = 200#m +#BOUNDINGBOX +RdX = lst[0] +RdY = lst[1] +Bbox = GIS2BIM.CreateBoundingBox(RdX,RdY,Bboxwidth,Bboxwidth,0) +print(Bbox) +======= from packages.GIS2BIM.GIS2BIM_CityJSON import * import time import ijson @@ -14,6 +33,7 @@ import certifi import ssl + def CreateFolder(Folder): #check and ccreate folders if not os.path.isdir(Folder): @@ -21,8 +41,13 @@ def CreateFolder(Folder): os.mkdir(Folder) #CITYJSON DOWNLOAD + +def DownloadCityJSON(): + kaartbladenres = kaartbladenBbox(Bbox, FolderCityJSON) +======= def DownloadCityJSON(Bbox, FolderCityJSON): kaartbladenres = kaartbladenBbox(Bbox) + print(kaartbladenres) for i in kaartbladenres: downloadlink = NLPDOKKadasterBasisvoorziening3DCityJSONVolledig + i[0] + "_2020_volledig.zip" @@ -66,6 +91,19 @@ def GetWebServerDataCategorised(obj1, obj2, obj3): jsonData = json.loads(url.read())[obj1][obj2][obj3] return jsonData + +#WMS +jsonobj=GetWebServerDataCategorised("GIS2BIMserversRequests", "NLwebserverRequests", "NLWMS") +serverrequestprefix= extract_values(jsonobj, 'serverrequestprefix') +title = extract_values(jsonobj, 'title') +print("ItemsToDownload: " + str(len(serverrequestprefix))) +print(FolderImages) +for i in range(len(serverrequestprefix)): + itemserverrequestprefix=serverrequestprefix[i] + itemtitle=title[i] + print(itemtitle) + WMSRequestNew(itemserverrequestprefix, Bbox, FolderImages + "/"+ itemtitle +".png", 1500, 1500) +======= def GetWebServerDataSettings(SettingsfileLocation): #get settings url = urllib.request.urlopen(SettingsfileLocation) @@ -229,4 +267,4 @@ def Create3DBag(Folder, RdX,RdY,LOD,Bboxwidth): GISProject.toSpeckle("6b2055857b", "3D Kadaster Basisvoorziening en 3D BAG") end = time.time() -print('Execution time:', end - start, 'seconds') \ No newline at end of file +print('Execution time:', end - start, 'seconds')