-
Notifications
You must be signed in to change notification settings - Fork 12
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
Osm tags #26
base: master
Are you sure you want to change the base?
Osm tags #26
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,13 +58,21 @@ public static void main(String[] args) throws Exception { | |
.withArgName("Z-LEVEL") | ||
.create() ); | ||
|
||
options.addOption( OptionBuilder.withLongOpt( "roadClass" ) | ||
.withDescription( "road class (default 6)" ) | ||
.hasArg() | ||
.withArgName("Z-LEVEL") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Z-LEVEL seems to be a copy paste error |
||
.create() ); | ||
|
||
|
||
String inputFile = ""; | ||
|
||
String outputPath = ""; | ||
|
||
Integer zLevel = 12 ; | ||
|
||
Integer roadClass = 6 ; | ||
|
||
try { | ||
// parse the command line arguments | ||
CommandLine line = parser.parse( options, args ); | ||
|
@@ -82,6 +90,10 @@ public static void main(String[] args) throws Exception { | |
if(line.hasOption("zlevel")){ | ||
zLevel = Integer.parseInt(line.getOptionValue("zlevel")); | ||
} | ||
|
||
if(line.hasOption("roadClass")){ | ||
roadClass = Integer.parseInt(line.getOptionValue("roadClass")); | ||
} | ||
Comment on lines
+94
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should really only one roadClass be processed or multiple? In #25, I assumed that multiple road classes should be processed? |
||
} | ||
catch( Exception exp ) { | ||
System.out.println( "Unexpected exception:" + exp.getMessage() ); | ||
|
@@ -113,10 +125,33 @@ public static void main(String[] args) throws Exception { | |
|
||
// list of way classes for export tiles (must be in sequential order from least to most filtered) | ||
ArrayList<Way.ROAD_CLASS> filteredClasses = new ArrayList<>(); | ||
filteredClasses.add(Way.ROAD_CLASS.ClassUnclassified); | ||
filteredClasses.add(Way.ROAD_CLASS.ClassTertiary); | ||
filteredClasses.add(Way.ROAD_CLASS.ClassPrimary); | ||
filteredClasses.add(Way.ROAD_CLASS.ClassMotorway); | ||
|
||
if(roadClass.intValue() == Way.ROAD_CLASS.ClassUnclassified.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassUnclassified); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassTertiary.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassTertiary); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassSecondary.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassSecondary); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassPrimary.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassPrimary); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassTrunk.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassTrunk); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassMotorway.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassUnclassified); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a typo? Shouldn't Way.ROAD_CLASS.ClassMotorway be added? |
||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassResidential.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassResidential); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassService.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassService); | ||
|
||
else if(roadClass.intValue() == Way.ROAD_CLASS.ClassOther.getValue()) | ||
filteredClasses.add(Way.ROAD_CLASS.ClassOther); | ||
Comment on lines
+128
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is repetitive and should be handled more compactly. |
||
|
||
for(Way.ROAD_CLASS filteredClass : filteredClasses) { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,47 +50,100 @@ public boolean isLink() { | |
|
||
} | ||
|
||
public String getName() { | ||
public boolean isDrivable() { | ||
|
||
if(fields.containsKey("name")) | ||
return fields.get("name").trim(); | ||
if(this.isHighway()) { | ||
if((fields.containsKey("motorcar'") && fields.get("motorcar").toLowerCase().equals("no") || fields.get("motorcar").toLowerCase().equals("false")) || | ||
(fields.containsKey("motor_vehicle") && fields.get("motor_vehicle").toLowerCase().equals("no") || fields.get("motor_vehicle").toLowerCase().equals("false")) || | ||
(fields.containsKey("vehicle") && fields.get("vehicle").toLowerCase().equals("no") || fields.get("vehicle").toLowerCase().equals("false")) || | ||
(fields.containsKey("access") && fields.get("motorcar").toLowerCase().equals("no") || fields.get("motorcar").toLowerCase().equals("false"))){ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
else | ||
return ""; | ||
return false; | ||
|
||
} | ||
|
||
public ROAD_CLASS roadClass() { | ||
public boolean isBikeable() { | ||
|
||
if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("motorway")) | ||
return ROAD_CLASS.ClassMotorway; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("trunk")) | ||
return ROAD_CLASS.ClassTrunk; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("primary")) | ||
return ROAD_CLASS.ClassPrimary; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("secondary")) | ||
return ROAD_CLASS.ClassSecondary; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("tertiary")) | ||
return ROAD_CLASS.ClassTertiary; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("unclassified")) | ||
return ROAD_CLASS.ClassUnclassified; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("residential")) | ||
return ROAD_CLASS.ClassResidential; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("service")) { | ||
|
||
// attempt to exclude parking lots, driveways and other private driveways to keep just public services roads | ||
// not consistently mapped in OSM... https://taginfo.openstreetmap.org/keys/?key=service#values | ||
if (fields.containsKey("service") && (fields.get("service").toLowerCase().trim().startsWith("parking") || | ||
fields.get("service").toLowerCase().trim().startsWith("driveway") || | ||
fields.get("service").toLowerCase().trim().startsWith("drive-through"))) | ||
return ROAD_CLASS.ClassOther; | ||
if (fields == null) | ||
return false; | ||
|
||
assert fields != null; | ||
|
||
return fields.containsKey("bikable"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps I'm missing something, but where comes the |
||
|
||
} | ||
|
||
public boolean isWalkable() { | ||
|
||
if (fields == null) | ||
return false; | ||
|
||
assert fields != null; | ||
|
||
return fields.containsKey("highway"); | ||
|
||
} | ||
|
||
public String getName() { | ||
|
||
String name = ""; | ||
|
||
if(fields.containsKey("name")) | ||
name = fields.get("name").trim(); | ||
|
||
if(fields.containsKey("ref")) { | ||
if(name.isEmpty()) | ||
name = fields.get("ref").trim(); | ||
else | ||
return ROAD_CLASS.ClassService; | ||
name += "; " + fields.get("ref").trim(); | ||
} | ||
|
||
return name; | ||
} | ||
|
||
public ROAD_CLASS roadClass() { | ||
|
||
|
||
if(fields.containsKey("highway")) { | ||
if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("motorway")) | ||
return ROAD_CLASS.ClassMotorway; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("trunk")) | ||
return ROAD_CLASS.ClassTrunk; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("primary")) | ||
return ROAD_CLASS.ClassPrimary; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("secondary")) | ||
return ROAD_CLASS.ClassSecondary; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("tertiary")) | ||
return ROAD_CLASS.ClassTertiary; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("unclassified")) | ||
return ROAD_CLASS.ClassUnclassified; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("residential")) | ||
return ROAD_CLASS.ClassResidential; | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("service")) { | ||
|
||
// attempt to exclude parking lots, driveways and other private driveways to keep just public services roads | ||
// not consistently mapped in OSM... https://taginfo.openstreetmap.org/keys/?key=service#values | ||
if (fields.containsKey("service") && (fields.get("service").toLowerCase().trim().startsWith("parking") || | ||
fields.get("service").toLowerCase().trim().startsWith("driveway") || | ||
fields.get("service").toLowerCase().trim().startsWith("drive-through"))) | ||
return ROAD_CLASS.ClassOther; | ||
else | ||
return ROAD_CLASS.ClassService; | ||
|
||
|
||
} else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("living_street")) | ||
return ROAD_CLASS.ClassResidential; | ||
else | ||
return ROAD_CLASS.ClassOther; | ||
} | ||
else { | ||
return ROAD_CLASS.ClassOther; // fall back to "other" for unknown | ||
} | ||
else if (fields.containsKey("highway") && fields.get("highway").toLowerCase().trim().startsWith("living_street")) | ||
return ROAD_CLASS.ClassResidential; | ||
else | ||
return ROAD_CLASS.ClassOther; | ||
} | ||
|
||
public boolean isRoundabout() { | ||
|
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.
As adding osm tags will have a substantial consequence on size of the generated tiles, could you elaborate a bit on the reasons why these are added? Perhaps this should be optional? Or at least the keys be filterable?