-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add jdbc import #556
Add jdbc import #556
Conversation
I tried to run this branch on the "mapcreator" account of new dev server, but I'm stuck with a very strange effect: Call to OsmFastCutter is returning immediatly, but the process is running on, so script is continuing with the second step (PosUnifier) but that fails... Probably has noting to to with the jdbc option, more with the new PBF-Parser? |
@abrensch So sounds as this is jdbc problem. |
A non-zero exit code would be smooth enough :-) However, I still do not understand why the process keeps running. Looks like a second thread forked or the like (?) |
@abrensch I was preparing for smoother handling, but not sure if it's a good idea to continue a process when no database call is in progress. The (incorrect) results will therefore only be displayed to you once the entire process has been completed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the specific comments I have some other remarks
.sql
and.lua
don't use a consistent format, perhaps run some formatter/beautifier- documentation in mapcreation folder: Should we keep it there or move it to docs?
- absolutly no tests: It requires quite some setup to import OSM data into postgis and process it. For tests we should perhaps use some (in-memory) SQLite database which has an
all_tags
table. - Is it possible to update the database using osm2pgsql?
- Should the database use more (materialized) views instead of tables because we don't need to modify the data?
@@ -165,6 +192,93 @@ private void generatePseudoTags(Map<String, String> map) { | |||
} | |||
|
|||
|
|||
// Ess Bee : NEW function to add the new tags (estimated_noise_class , river, forest...) | |||
|
|||
private void generateSpecialTags(long osm_id, Map<String, String> map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Special doesn't tell much about the tags. Perhaps generateTagsFromDatabase
?
// Ess Bee : NEW function to add the new tags (estimated_noise_class , river, forest...) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove coment
|
||
String sql_all_tags = "SELECT * from all_tags where losmid = ?"; | ||
|
||
System.err.println("OsmCutter start connection to the database........" + jdbcurl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not an error, should not print to standard error.
conn = DriverManager.getConnection(jdbcurl); | ||
psAllTags = conn.prepareStatement(sql_all_tags); | ||
|
||
System.err.println("OsmCutter connect to the database ok........"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not an error, should not print to standard error.
if (rsBrouter.getString("noise_class") != null) { | ||
map.put("estimated_noise_class", rsBrouter.getString("noise_class")); | ||
cntNewNoise = cntNewNoise + 1; | ||
} | ||
if (rsBrouter.getString("river_class") != null) { | ||
map.put("estimated_river_class", rsBrouter.getString("river_class")); | ||
cntNewRiver = cntNewRiver + 1; | ||
} | ||
if (rsBrouter.getString("forest_class") != null) { | ||
map.put("estimated_forest_class", rsBrouter.getString("forest_class")); | ||
cntNewForest = cntNewForest + 1; | ||
} | ||
|
||
if (rsBrouter.getString("town_class") != null) { | ||
map.put("estimated_town_class", rsBrouter.getString("town_class")); | ||
cntNewTown = cntNewTown + 1; | ||
} | ||
|
||
if (rsBrouter.getString("traffic_class") != null) { | ||
map.put("estimated_traffic_class", rsBrouter.getString("traffic_class")); | ||
cntNewTraffic = cntNewTraffic + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of copy-pase code. We should store source tags and BRouter tags in a map and just lookup the mapping. Same would work for those counters.
|
||
System.err.println("OsmCutter start connection to the database........" + jdbcurl); | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This try-block shoudn't be nested in the if (conn == null)
block
if (args.length != 11 && args.length != 12) { | ||
String common = "java OsmFastCutter <lookup-file> <node-dir> <way-dir> <node55-dir> <way55-dir> <border-file> <out-rel-file> <out-res-file> <filter-profile> <report-profile> <check-profile>"; | ||
if (args.length != 11 && args.length != 12 && args.length != 13) { | ||
String common = "java OsmFastCutter <lookup-file> <node-dir> <way-dir> <node55-dir> <way55-dir> <border-file> <out-rel-file> <out-res-file> <filter-profile> <report-profile> <check-profile> <map-file> <jdbc-url>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional parameters are usually in square brackets e.g. [jbdc-url]
misc/scripts/mapcreation/brouter.sql
Outdated
@@ -0,0 +1,649 @@ | |||
-- calculation of new tags (estimated_noise_class, estimated_river_class,estimated_forest_class, estimated_town_class, estimated_traffic_class) | |||
-- Ess Bee version 08/05/2023 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use git for versioning, not an additional number
Not easy to find a formatter, most breaking on postgres functions. I used https://sqlformat.darold.net/ online formatting for now, but also this breaks with errors on database generation. That needs more time.
Yes, we should. But at the moment this is more a todo list for finding a right script for generation.
Yes, and I don't have an idea for a change. The scripts need postgres functions. So a SQLite could only hold pregenerated values. But that is a fake test.
I hope so. But it is not developed or tested.
This is not tested as well. But yes, it is an idea for the future. |
I don't get it.... |
That is the way it works. Please see this line in nextWay routine. I was able to check it in my logs. But the mapping to "jdbc:oracle:..." sounds strange. |
Blame on me... the "&" in the jdbc-url is interpreted by the shell... just needs quotes. |
It's pretty common to use mocks/fakes/doubles to test functionality on a unit or module level. This also establishes a clear boundary because you can easily see which data is expected by |
This is according to discussion #486 and adds tags via database call to the way generation.
New is
forest to find nice ways in or near forest
river to file ways along water
noise to avoid bigger streets
town to avoid bigger citys
traffic was used before but is now generated by database call
The classpath in generation needs a jdbc driver
and the OsmFastCutter a call with some database parameter
Please see readme.
There is also a new lookups.dat that contains the new tags - before the node context. This should be neutral to older versions.
In the next generation lookups.dat (#458) I would prefer these new tags more moved up to get smaller rd5 files.
This needs also an update for the profiles to make use of the new tags.