berthubert / bagconv Goto Github PK
View Code? Open in Web Editor NEWConvert Dutch building/dwelling administration into a simpler format
License: MIT License
Convert Dutch building/dwelling administration into a simpler format
License: MIT License
The method that returns an object given a latitude and longitude (bag.nl/x/y) is really useful, but would hugely benefit from also returning a zip or postcode per object. Perhaps there's some other way to get pcodes from coordinates?
There are no coordinates (i.e. -1.0,-1.0) for e.g.:
straat | huisnummer | huisletter | huistoevoeging | woonplaats | postcode | x | y | lon | lat | oppervlakte | gebruiksdoelen | num_status | vbo_status | vbo_type | num_id | vbo_id | opr_id |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Piekenwaardweg | 10 | a | 202 | Kerkdriel | 5331PD | -1.0 | -1.0 | 3.31357161339861 | 47.9747577455202 | -1 | [] | Naamgeving uitgegeven | Plaats aangewezen | sta | 0263200000366237 | 0263030000012451 | 0263300000000417 |
This seems to be the case for all non-vbo vbo_types, as can be confirmed by the following SQL query returning 0 results:
SELECT * FROM unilabel WHERE vbo_type <> 'vbo' AND x <> -1.0;
pcodes-geo.zip contains lots of invalid locations (x=-1, y=-1) and it appears that these are (mostly?) ships.
bagserv gives no output at all for such addresses. E.g. 2231BG 293.
(btw the official BAG viewer map also seems to struggle a bit: The location (blue dot) only appears on the map after a search but not after clicking on the object)
Turns out the huisletter can officially be lower case, in which case we often won't find it.
Either we need to do some SQLite magic, or provide a guaranteed upper case version for searches.
We now always believe the "newest" version. However, for example for num ID 0302200000188380 the BAG contains news that a house number will change per 1st of July (which it isn't yet). But we believe it already.
I think it would be neat if bagserv would also provide a way to search using RD-coordinates.
I've tried implementing it using this code, but I think something is wrong with the SQL query; which I can imagine since I just copied the WGS84 search and changed lat to x and lon to y. What would be the proper way to implement this?
diff --git a/bagserv.cc b/bagserv.cc
index e268c14..8f8dcf4 100644
--- a/bagserv.cc
+++ b/bagserv.cc
@@ -139,7 +139,25 @@ int main(int argc, char**argv)
}
});
-
+ // Search based on RD coordinates in the form of /rd/{x}/{y}
+ svr.Get(R"(/rd/(\d*\.\d*)/(\d*\.\d*))", [&sqw, &sqwlock](const httplib::Request &req, httplib::Response &res) {
+ try {
+ auto xstr = (string)req.matches[1];
+ auto ystr = (string)req.matches[2];
+ double x = atof(xstr.c_str());
+ double y = atof(ystr.c_str());
+ cout<<"Query for "<< x <<", "<< y <<endl;
+ vector<unordered_map<string,string>> result;
+ {
+ std::lock_guard<mutex> l(sqwlock);
+ result=sqw.query("select x as rdX, y as rdY,straat,woonplaats,huisnummer,huisletter,huistoevoeging,oppervlakte,bouwjaar,lon,lat,gebruiksdoel,num_status,vbo_status, (x-?)*(x-?)+(y-?)*(y-?) as deg2dist from geoindex,alllabel where alllabel.vbo_id = geoindex.vbo_id and minX > ? and maxX < ? and minY > ? and maxY < ? order by deg2dist asc limit 1", {x, x, y, y, x-0.005, x+0.005, y-0.005, y+0.005});
+ }
+ res.set_content(packResults(result), "application/json");
+ }
+ catch(exception& e) {
+ cerr<<"Error: "<<e.what()<<endl;
+ }
+ });
svr.listen("0.0.0.0", argc==1 ? 8080 : atoi(argv[1]));
}
Sometimes e.g. house numbers are changed. It would be great if it would be easier to find historical addresses (by searching with e.g. the old house number) and also e.g. be able to find the current address for it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.