Skip to content

Spatial Rule Lookup (e.g. Country Specific Rules) - #926

Merged
karussell merged 43 commits into
graphhopper:masterfrom
boldtrn:issue_175
Feb 20, 2017
Merged

karussell merged 43 commits into
graphhopper:masterfrom
boldtrn:issue_175

Conversation

@boldtrn

@boldtrn boldtrn commented Dec 30, 2016 •

Copy link
Copy Markdown
Member

This PR intents to solve #175.

The basic data structure is an array, that separates the world (or an area) into tiles, with a given resolution. Each tile contains a reference to a set of rules.

Rules contain a set of polygons in which their rules are valid. Using an array has to disadvantages: (1) covering unused space, e.g. water and (2) inexact resoultion. Currently the default resolution about 20*20km at the equator (0.1 degree). We can achieve exact results when doing a Polygon contains check, which can be configured.

Right now I prepared two set of rules, Austria and Germany, but rules can be written for every Country. All countries are available in the countries.geo.json file. This file is based on the admin levels from NaturalEarthData taken from this repo under public domain. As the file would be 25mb, is reduced it to 10% using DP. Therefore the borders are sometimes slightly inaccurate (should not be too bad, otherwise let me know).

Lookup speed is not too bad. 10 000 000 lookups in an area that is filled approximately half by a polyong, takes between 3-4 seconds on my machine.

TODOs:

  • Nr of rules is currently limited to 255, but since we have to create a new rule for every unique set of country borders, the array might be with 20-30 countries, depending on the borders.
  • The SpatialLookup is currently created in the web module. It would be better if we could have it as Storable<LocationIndex>. That way we could load it, once it was created (even though creation is quite fast). Also I am not sure how to do this (especially with the rule reference array, the lookup array should be easy)?
  • How to evaluate these rules? Currently I do this in the DataFlagEncoder, however it might be better to do this in the GenericWeighting? IMHO the DataFlagEncoder is representing the tags of a given source (e.g. OSM), but not business logic. For example we are also not saving the default max speeds in the edge, but calculate it every time in the GenericWeighting
  • Consider using the exact country borders - would slow down the Polygon contains approx. 10 times. Also we have to host this file, as IMHO 25mb should not be put into the repo.
  • Differentiate between Polygon and Multipolygon? -> Later
  • Add Javadoc to the Interfaces
  • Make spatial index configureable. What rules to load and if it should be used at all.

Let me know what you think. Currently this is still work in progress, so any comments are more than welcome.

@karussell

karussell commented Dec 30, 2016 •

Copy link
Copy Markdown
Member

Thanks - will have a look!

As the file would be 25mb, is reduced it to 10% using DP (douglas peucker)

Maybe this is not too critical. How large is the 25mb file if compressed? As git and jar normally does compression and it will be big just on the disc and not in production.

@karussell
karussell self-requested a review December 30, 2016 09:44
@karussell karussell mentioned this pull request Dec 30, 2016
12 tasks done
@boldtrn

boldtrn commented Dec 31, 2016

Copy link
Copy Markdown
Member Author

How large is the 25mb file if compressed?

2.5mb. You can view the file here: http://bl.ocks.org/d/7280192619e0cc25f609dafe5c0de2cf

I think the borders are not too bad, but we can definetly use the exact borders if this becomes an issue.

@boldtrn boldtrn self-assigned this Dec 31, 2016

@karussell karussell left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments but will play with it in the next day to get a feeling how this should look like when applied in a different context (#780) and give you further suggestions or already do some refactorings...


@Override
public GHPoint asPoint() {
return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in asPointList we need to throw UnsupportedExc


/**
* This interface is used to define an area or location being used to block or change areas in the graph.
* This interface is used to define an area or location in a geojson file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface has nothing to do with a file. Maybe we just say define an area or location in a GeoJSON fashion?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups, you'r right :)

this.nonChMaxWaypointDistance = nonChMaxWaypointDistance;
}

public void setSpatialRuleLookup(SpatialRuleLookup spatialRuleLookup) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmh, I do not like this procedure much. We should not provide a setter here, if this is not an additional thing for GraphHopper (infact GraphHopper.spatialRuleLookup is unused).

Instead the user should/could do graphHopper.getEncodingManager().getEncoder("generic").setXY ... or maybe independent on generic and just graphHopper.getEncodingManager().setXY?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍 I think it makes sense to start only with generic for now. We can always extend that.

accessValue = getEdgeValueForAccess(rule.isAccessible(way, ""));
}

}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the idea was to first check the ReaderWay if there is an access restriction value on it. If not check the country rules to eventually add a restriction.

*
* @author Robin Boldt
*/
public class Polygon {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs more javadocs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some, probably still needs more :)


@Override
public String getType() {
return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should return Polygon or MultiPolygon or create two implementations?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Polygon for now. We definitely have to think about how we handle this in the future.


The Geojson has roughly 25MB, so I reduced it with http://www.mapshaper.org/ using Douglas Peuckar at 10%. The resulting file is 2.4mb.

The rules are taken from the OSM Wiki: ttps://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in the NOTICE.md instead (?)

And why is this and countries.geo.json in package com/graphhopper/http ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in the NOTICE.md instead (?)

Yes thats correct. I wanted to fix this once we have a final location for the countries.geo.json.

And why is this and countries.geo.json in package com/graphhopper/http ?

Currently I load the countries.geo.json with SpatialRuleLookupBuilder.class.getResource("countries.geo.json") and SpatialRuleLookupBuilder is in com.graphhopper.http. I had it in the core first, but wasn't able to read the file in all cases (I think when running the tests with Maven).

GraphHopper tmp = new GraphHopperOSM().forServer().init(args);
//TODO We should set the BBox and resolution
//TODO, move to a more appropriate place
tmp.setSpatialRuleLookup(SpatialRuleLookupBuilder.build());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to the TODOs :) ... it is suboptimal that it cannot be configured where to load the json from and the resolution ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know :) I should fix this.

GHJson ghJson = new GHJsonBuilder().create();
JsonFeatureCollection jsonFeatureCollection = ghJson.fromJson(new FileReader(new File(SpatialRuleLookupBuilder.class.getResource("countries.geo.json").getFile())), JsonFeatureCollection.class);

// TODO find outer Border of all used features and create SpatialRuleLookupArray onlyo for these Bounds

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean here?

(+minor spelling issues)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to calculate a BBox for all SpatialRules. Initializing an Array for world wide coverage makes no sense If we only have a rule for a subset of the world (e.g., Germany and Austria). Would be quite easy to do and would save quite some storage.

}
}
} catch (FileNotFoundException e) {
e.printStackTrace();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please never catch exceptions and continue silently. Instead rethrow e.g. via new RuntimeException(e)

@karussell

Copy link
Copy Markdown
Member

Have now pushed a change suggestion.

BTW: The same config is now ensured via the spatial_rules number. The height&width etc config are similarly ensured already.


public DataFlagEncoder setSpatialRuleLookup(SpatialRuleLookup spatialRuleLookup) {
if (spatialRuleLookup.size() != spatialRules)
throw new IllegalArgumentException("You have to configure the encoder to accept the identical amount of rules " +

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we get the number of spatial rules from the lookup then? But the lookup isn't available when constructing the encoder?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly that can be the problem

"|store_weight=" + storeWeight +
"|store_width=" + storeWidth;
"|store_width=" + storeWidth +
"|spatial_rules=" + spatialRules;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we safe the order and name of the countries? Or would this be too much overhead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now lets keep it simple and a bit unsafer until we have something better :)

double getMaxSpeed(String highway, double _default);

AccessValue isAccessible(String highwayTag, String transportationMode, AccessValue _default);
AccessValue getAccessible(String highwayTag, String transportationMode, AccessValue _default);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAccessValue or getAccessibility?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes getAccessValue

@boldtrn boldtrn left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general your changes look good to me. The only thing that bothers me is that we don't evaluate the SpatialRules in the GenericWeighting (or I missed it). So right now we safe the country but don't use the information?

*
* @author Robin Boldt
*/
public interface SpatialRule {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about the SpatialRule a bit more I think we should make it definitely more generic. But I think we should do this in a future improvement. First merge this one :)


/**
* Contains SpatialRules
* This class contains a collection of SpatialRule and is used for the implementation SpatialRuleLookupArray.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class contains a collection of SpatialRules. It is used to define multiple rules per tile in the SpatialRuleLookupArray.

Not sure if this is better?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that might be better 👍 I think this also follows more the standard behavior of Java Collections.

* The covered area is indexed as tiles, with every tile being "quadratic" having the same degree length on every side.
* <p>
* Currently one one rule per Tile is allowed. The later added rule will be added to the tile.
* Currently only a limited amount of rule combinations per tile are allowed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? Obviously limited to 255, but you could put Integer.MAX_VALUE amount of rules per container and therefore per tile.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not limited to the number of rules per container but to the number of rule combinations. E.g. A,B is one combination then A,B,D is another and so on. So maybe not that clear description?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is it really limited per tile? It is limited for the whole lookup, but not per tile.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, it is the whole lookup

SpatialRuleLookupArray(BBox bounds, double resolution, boolean exact) {
if (bounds == null)
throw new IllegalArgumentException("BBox cannot be null");
if (resolution < 1e-100)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this beside just generically limiting the resoultion. BTW: I don't think anyone will need a finer resolution, just asking :).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is resolution<=0 is not what we want and maybe we can raise this limit here a bit but not lower it IMO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am perfectly fine with the limit, I was just wondering why it is that number :).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just picked a very small one - maybe we can increase it with some assumption

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's fine. Was just wondering.


protected int getRuleIndex(int xIndex, int yIndex) {
protected int getRuleContainerIndex(int xIndex, int yIndex) {
if (xIndex < 0 || xIndex > lookupArray.length) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the lat lon checks in the lookupRule method in favor of this check. This might safe some overhead? This should be also very fast. I think we should do some performance measures here? But that is something we can consider later anyway. Create an issue for this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, usually ifs for boundary checks are very fast. For now I wouldn't care that much. But we could check the result (in lookupRule) for EMPTY_RULE_INDEX and return EMPTY instead of the call to ruleContainers etc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's just leave it as is. If we see any performance issues we can still tweak?

lookupArray[i][j] = (byte) ruleIndex;
lookupArray[i][j] = (byte) ruleContainerIndex;
} else {
// Merge Rules

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract the merge rules logic into a new method?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted already a bit ... it is ok for now IMO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I saw that. Should be fine.

}

public void visualize(int stepSize) {
void sout(int stepSize) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete that one. I used it in the beginning to debug the lookup.

GHJson ghJson = new GHJsonBuilder().create();
JsonFeatureCollection jsonFeatureCollection = ghJson.fromJson(reader, JsonFeatureCollection.class);
return new SpatialRuleLookupBuilder().build(
Arrays.asList(new GermanySpatialRule(), new AustriaSpatialRule()),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make the Countries configureable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do it with reflection? Maybe later?

if (time == Long.MAX_VALUE)
return Double.POSITIVE_INFINITY;

int spatialId = gEncoder.getSpatialId(edgeState.getFlags());

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I missed it or is the SpatialIndex actually unused now? We safe the CountryId but don't evaluate it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, yes. But we could apply speed and access changes when feeding here: https://github.com/boldtrn/graphhopper/blob/59b7e435f11628507cdbc254d27f7ceb3b31501d/core/src/main/java/com/graphhopper/routing/util/DataFlagEncoder.java#L408

I would avoid putting the index in the GenericWeighting ... too many things already there and as we could change speed and accessibility when feeding this is also not necessary for now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to add applying the speed and accessibility changes and recover may some tests that I removed? This seems indeed important to me, now that you pointed me to it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to add applying the speed and accessibility changes and recover may some tests that I removed? This seems indeed important to me, now that you pointed me to it

So should I put it back into the GenericWeighting? Or should we keep it in the DataFlagEncoder?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please for now without GenericWeighting. So like I linked: determine the country and apply a speed reduction if necessary (similar with the access).

ghost Feb 14, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to add applying the speed and accessibility changes and recover may some tests that I removed? This seems indeed important to me, now that you pointed me to it

Added these back to the DataFlagEncoder.

@karussell

ghost commented Feb 9, 2017

Copy link
Copy Markdown
Member

(BTW: also please have a look at some comments we made at 'outdated' commits here in this PR :))

maxSpeed = getSpatialRule(way).getMaxSpeed(way.getTag("highway", ""), maxSpeed);
}
double fwdSpeed = parseSpeed(way.getTag("maxspeed:forward"));
if (fwdSpeed < 0 || maxSpeed > 0 && maxSpeed < fwdSpeed)

ghost Feb 14, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fwdSpeed > maxSpeed an iillegal/unwanted state? From a mapping perspective it shouldn't matter, right?

ghost Feb 14, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be allowed, yes.

@boldtrn

ghost commented Feb 14, 2017

Copy link
Copy Markdown
Member Author

Ok, so I updated this PR. Are we good to merge it or is there anything we should add/change?

return false;
}

private SpatialRule getSpatialRule(ReaderWay way) {

ghost Feb 14, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this method used?

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be removed?

assertEquals(index.getSpatialId(SpatialRule.EMPTY), encoder.getSpatialId(e2.getFlags()));

assertEquals(AccessValue.EVENTUALLY_ACCESSIBLE, encoder.getAccessValue(e1.getFlags()));
assertEquals(AccessValue.ACCESSIBLE, encoder.getAccessValue(e2.getFlags()));

ghost Feb 14, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to add a further test where the max_speed value is overwritten by the one stored in the index?

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I scanned over the changes once again and found two bugs and some other minor things. Afterwards I think we are good to merge. Finally :)

private EncodedValue highwayEncoder;
private EncodedValue transportModeEncoder;
private EncodedValue accessEncoder;
private static int NOT_ACCESSIBLE_KEY;

ghost Feb 16, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the static has to be removed. static is almost always code smell and/or dangerous/buggy (at least without final)

ghost Feb 20, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That variable wasn't used :)

ghost Feb 20, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow I cannot comment on your comment below.

Can it be removed?

Yes, but it is used two times in the code. This would most probably lead to duplicated code. So I wouldn't want to do this, only if we have to?

ghost Feb 20, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it is used two times in the code. This would most probably lead to duplicated code. So I wouldn't want to do this, only if we have to?

Ok

maxSpeed = getSpatialRule(way).getMaxSpeed(way.getTag("highway", ""), maxSpeed);
}
double fwdSpeed = parseSpeed(way.getTag("maxspeed:forward"));
if (fwdSpeed < 0 || maxSpeed > 0 && maxSpeed < fwdSpeed)

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmh, sorry. When I think more about this: removing this is incorrect. Assume maxspeed=60 and maxspeed:forward=50 should result in fwdSpeed==50 so what we probably need is fwdSpeed < 0 && maxSpeed > 0 - would you add another test? (Similar fix needed for bwdSpeed)

ghost Feb 20, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. Added another test.

return false;
}

private SpatialRule getSpatialRule(ReaderWay way) {

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be removed?

/**
* Get the unique name for this rule, e.g. the ISO name of the country.
*/
String getUniqueName();

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to getId?

ghost Feb 20, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at first I did not want to call it id, but this should be easier to understand and also imply that it should be unique. But I think it makes sense to rename it.

}
}

if (polygonBounds.minLon == Double.MAX_VALUE) {

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it is safer to use !polygonBounds.isValid() instead

}
System.out.println();
}
}

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you said this is no longer used/needed: would you mind to remove it?

case "motorway":
return Integer.MAX_VALUE;
case "trunk":
return Integer.MAX_VALUE;

ghost Feb 16, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but should be probably explicitly mentioned in the javadocs of the interface?

@karussell karussell added this to the 0.9 milestone Feb 16, 2017
@boldtrn

ghost commented Feb 20, 2017

Copy link
Copy Markdown
Member Author

I updated this PR and added JavaDoc to the Interfaces. I realized that passing a string as TransportationMode is not a good idea and changed it to be an enum (sorry for the last minute change). I feel like it makes more sense like that. This enum could be used in the DataFlagEncoder to differ between different TransportationModes as well.

@karussell

ghost commented Feb 20, 2017

Copy link
Copy Markdown
Member

Nice - Thanks!

* This class represents a polygon that is defined by a set of points.
* Every point i is connected to point i-1 and i+1.
* <p>
* TODO: Howto design inner rings in the polygon?

ghost Feb 20, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we do this here #956

@karussell
karussell merged commit 15c0723 into graphhopper:master Feb 20, 2017
@boldtrn
boldtrn deleted the issue_175 branch February 21, 2017 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants