Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
DutchSailor committed Oct 7, 2024
1 parent eadf924 commit 56d7a7f
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 5 deletions.
129 changes: 129 additions & 0 deletions sandbox/Versie juni 2024/example/GIS2BIM/NL_0_geocoding test.py
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 6 additions & 4 deletions sandbox/Versie juni 2024/example/GIS2BIM/NL_3_Cadaster.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,26 +24,26 @@
# 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)

# img = imagePyB().by_file(fileLocationWMS,Bboxwidth*1000,Bboxwidth*1000,0,0,0)
# 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):
Expand Down
40 changes: 39 additions & 1 deletion sandbox/Versie juni 2024/example/GIS2BIM/NL_DownloadBasis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,15 +33,21 @@
import certifi
import ssl


def CreateFolder(Folder):
#check and ccreate folders
if not os.path.isdir(Folder):
print(Folder + ": " + str(os.path.isdir(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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
print('Execution time:', end - start, 'seconds')

0 comments on commit 56d7a7f

Please sign in to comment.