name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
graphhopper_VectorTile_getLayersBuilder_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public VectorTile.Tile.Layer.Builder getLayersBuilder(int index) {
return getLayersFieldBuilder().getBuilder(index);
}
| 3.26 |
graphhopper_VectorTile_addKeys_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public Builder addKeys(String value) {
if (value == null) {
throw new NullPointerException();
}
ensureKeysIsMutable();
keys_.add(value);
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_m12_rdh
|
/**
* <pre>
* The type of geometry stored in this feature.
* </pre>
*
* <code>optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN];</code>
*/
public boolean m12() {
return (bitField0_ & 0x2) ==
0x2;
}
| 3.26 |
graphhopper_VectorTile_m23_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public VectorTile.Tile.LayerOrBuilder m23(int index) {
return layers_.get(index);
}
| 3.26 |
graphhopper_VectorTile_setType_rdh
|
/**
* <pre>
* The type of geometry stored in this feature.
* </pre>
*
* <code>optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN];</code>
*/
public Builder setType(VectorTile.Tile.GeomType value) {
if (value == null) {
throw new NullPointerException();
}bitField0_ |= 0x4;
type_ = value.getNumber();
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_getTagsCount_rdh
|
/**
* <pre>
* Tags of this feature are encoded as repeated pairs of
* integers.
* A detailed description of tags is located in sections
* 4.2 and 4.4 of the specification
* </pre>
*
* <code>repeated uint32 tags = 2 [packed = true];</code>
*/
public int getTagsCount() {
return tags_.size();
}
| 3.26 |
graphhopper_VectorTile_hasIntValue_rdh
|
/**
* <code>optional int64 int_value = 4;</code>
*/
public boolean hasIntValue() {
return (bitField0_ & 0x8) == 0x8;
}
| 3.26 |
graphhopper_VectorTile_setKeys_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public Builder setKeys(int index, String value)
{
if (value == null) {
throw new
NullPointerException();
}
ensureKeysIsMutable();keys_.set(index, value);
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_getValuesOrBuilder_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public VectorTile.Tile.ValueOrBuilder getValuesOrBuilder(int index) {
if (valuesBuilder_ == null) {
return values_.get(index);
} else {
return valuesBuilder_.getMessageOrBuilder(index);
}
}
| 3.26 |
graphhopper_VectorTile_getIntValue_rdh
|
/**
* <code>optional int64 int_value = 4;</code>
*/
public long getIntValue() {
return intValue_;
}
| 3.26 |
graphhopper_VectorTile_hasType_rdh
|
/**
* <pre>
* The type of geometry stored in this feature.
* </pre>
*
* <code>optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN];</code>
*/
public boolean hasType() {
return (bitField0_ & 0x4) == 0x4;
}
| 3.26 |
graphhopper_VectorTile_addFeaturesBuilder_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public VectorTile.Tile.Feature.Builder addFeaturesBuilder(int index) {
return getFeaturesFieldBuilder().addBuilder(index, VectorTile.Tile.Feature.getDefaultInstance());
}
| 3.26 |
graphhopper_VectorTile_getFeaturesCount_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public int getFeaturesCount() {
return features_.size();
}
| 3.26 |
graphhopper_VectorTile_m18_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/public int m18() {
return keys_.size();
}
| 3.26 |
graphhopper_VectorTile_getLayersBuilderList_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public List<VectorTile.Tile.Layer.Builder> getLayersBuilderList()
{
return getLayersFieldBuilder().getBuilderList();
}
| 3.26 |
graphhopper_VectorTile_clearBoolValue_rdh
|
/**
* <code>optional bool bool_value = 7;</code>
*/
public Builder clearBoolValue() {
bitField0_ = bitField0_ & (~0x40);
boolValue_ = false;onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_setBoolValue_rdh
|
/**
* <code>optional bool bool_value = 7;</code>
*/
public Builder setBoolValue(boolean value) {
bitField0_ |= 0x40;
boolValue_ = value;
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_clearStringValue_rdh
|
/**
* <pre>
* Exactly one of these values must be present in a valid message
* </pre>
*
* <code>optional string string_value = 1;</code>
*/
public Builder clearStringValue() {
bitField0_ = bitField0_ & (~0x1);
stringValue_ = getDefaultInstance().getStringValue();
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_getVersion_rdh
|
/**
* <pre>
* Any compliant implementation must first read the version
* number encoded in this message and choose the correct
* implementation for this version number before proceeding to
* decode other parts of this message.
* </pre>
*
* <code>required uint32 version = 15 [default = 1];</code>
*/
public int getVersion() {
return version_;
}
| 3.26 |
graphhopper_VectorTile_getLayersList_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public List<VectorTile.Tile.Layer> getLayersList() {
if (layersBuilder_ == null) {
return Collections.unmodifiableList(layers_);
} else {
return layersBuilder_.getMessageList();
}
}
| 3.26 |
graphhopper_VectorTile_setGeometry_rdh
|
/**
* <pre>
* Contains a stream of commands and parameters (vertices).
* A detailed description on geometry encoding is located in
* section 4.3 of the specification.
* </pre>
*
* <code>repeated uint32 geometry = 4 [packed = true];</code>
*/
public Builder setGeometry(int index, int value) {
ensureGeometryIsMutable();
geometry_.set(index, value);
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_addAllValues_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public Builder addAllValues(Iterable<? extends VectorTile.Tile.Value>
values) {
if (valuesBuilder_ == null) {
ensureValuesIsMutable();
AbstractMessageLite.Builder.addAll(values, values_);
onChanged();
} else {
valuesBuilder_.addAllMessages(values);
}
return this;
}
| 3.26 |
graphhopper_VectorTile_getGeometryCount_rdh
|
/**
* <pre>
* Contains a stream of commands and parameters (vertices).
* A detailed description on geometry encoding is located in
* section 4.3 of the specification.
* </pre>
*
* <code>repeated uint32 geometry = 4 [packed = true];</code>
*/
public int getGeometryCount() {
return geometry_.size();
}
| 3.26 |
graphhopper_VectorTile_clearFloatValue_rdh
|
/**
* <code>optional float float_value = 2;</code>
*/
public Builder clearFloatValue() {
bitField0_ = bitField0_ & (~0x2);floatValue_ = 0.0F;
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_m9_rdh
|
/**
* <code>optional int64 int_value = 4;</code>
*/
public Builder m9() {
bitField0_ = bitField0_ & (~0x8);
intValue_ = 0L;onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_clearFeatures_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public Builder clearFeatures() {
if (featuresBuilder_ == null) {
features_ = Collections.emptyList();
bitField0_ = bitField0_ & (~0x4);
onChanged();
} else {
featuresBuilder_.clear();
}
return this;
}
| 3.26 |
graphhopper_VectorTile_setValues_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public Builder setValues(int index, VectorTile.Tile.Value.Builder builderForValue) {
if (valuesBuilder_ == null)
{
ensureValuesIsMutable();
values_.set(index, builderForValue.build());onChanged();
} else {
valuesBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
| 3.26 |
graphhopper_VectorTile_removeValues_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public Builder removeValues(int index) {
if (valuesBuilder_ == null) {
ensureValuesIsMutable();
values_.remove(index);
onChanged();
}
else {
valuesBuilder_.remove(index);
}
return this;
}
| 3.26 |
graphhopper_VectorTile_valueOf_rdh
|
/**
*
* @deprecated Use {@link #forNumber(int)} instead.
*/
@Deprecated
public static GeomType valueOf(int value) {
return forNumber(value);
}
| 3.26 |
graphhopper_VectorTile_m14_rdh
|
/**
* <pre>
* Tags of this feature are encoded as repeated pairs of
* integers.
* A detailed description of tags is located in sections
* 4.2 and 4.4 of the specification
* </pre>
*
* <code>repeated uint32 tags = 2 [packed = true];</code>
*/
public Builder m14(int index, int value) {
ensureTagsIsMutable();tags_.set(index, value);
onChanged();
return this; }
| 3.26 |
graphhopper_VectorTile_getGeometryList_rdh
|
/**
* <pre>
* Contains a stream of commands and parameters (vertices).
* A detailed description on geometry encoding is located in
* section 4.3 of the specification.
* </pre>
*
* <code>repeated uint32 geometry = 4 [packed = true];</code>
*/public List<Integer> getGeometryList() {
return Collections.unmodifiableList(geometry_);
}
| 3.26 |
graphhopper_VectorTile_setDoubleValue_rdh
|
/**
* <code>optional double double_value = 3;</code>
*/
public Builder setDoubleValue(double value) {
bitField0_ |= 0x4;
doubleValue_ = value;
onChanged();
return this;}
| 3.26 |
graphhopper_VectorTile_addFeatures_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public Builder addFeatures(int index, VectorTile.Tile.Feature.Builder builderForValue) {
if (featuresBuilder_ == null) {
ensureFeaturesIsMutable();
features_.add(index, builderForValue.build());
onChanged();
} else { featuresBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
| 3.26 |
graphhopper_VectorTile_hasBoolValue_rdh
|
/**
* <code>optional bool bool_value = 7;</code>
*/
public boolean hasBoolValue() {
return (bitField0_ & 0x40) == 0x40;
}
| 3.26 |
graphhopper_VectorTile_getFeaturesOrBuilderList_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public List<? extends VectorTile.Tile.FeatureOrBuilder>
getFeaturesOrBuilderList() {
if (featuresBuilder_ != null) {return featuresBuilder_.getMessageOrBuilderList();} else {
return Collections.unmodifiableList(features_);
}
}
| 3.26 |
graphhopper_VectorTile_getFeaturesBuilderList_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public List<VectorTile.Tile.Feature.Builder> getFeaturesBuilderList() {return getFeaturesFieldBuilder().getBuilderList();
}
| 3.26 |
graphhopper_VectorTile_hasFloatValue_rdh
|
/**
* <code>optional float float_value = 2;</code>
*/
public boolean hasFloatValue() {
return (bitField0_ & 0x2) == 0x2;
}
| 3.26 |
graphhopper_VectorTile_m21_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public List<VectorTile.Tile.Value.Builder> m21() {
return getValuesFieldBuilder().getBuilderList();
}
| 3.26 |
graphhopper_VectorTile_getKeysCount_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public int getKeysCount() {
return keys_.size();}
| 3.26 |
graphhopper_VectorTile_addGeometry_rdh
|
/**
* <pre>
* Contains a stream of commands and parameters (vertices).
* A detailed description on geometry encoding is located in
* section 4.3 of the specification.
* </pre>
*
* <code>repeated uint32 geometry = 4 [packed = true];</code>
*/
public Builder addGeometry(int value) {
ensureGeometryIsMutable();
geometry_.add(value);
onChanged();
return this;}
| 3.26 |
graphhopper_VectorTile_hasName_rdh
|
/**
* <code>required string name = 1;</code>
*/
public boolean hasName() {
return (bitField0_ & 0x2) == 0x2;
}
| 3.26 |
graphhopper_VectorTile_getTags_rdh
|
/**
* <pre>
* Tags of this feature are encoded as repeated pairs of
* integers.
* A detailed description of tags is located in sections
* 4.2 and 4.4 of the specification
* </pre>
*
* <code>repeated uint32 tags = 2 [packed = true];</code>
*/
public int getTags(int index) {return tags_.get(index);
}
| 3.26 |
graphhopper_VectorTile_setVersion_rdh
|
/**
* <pre>
* Any compliant implementation must first read the version
* number encoded in this message and choose the correct
* implementation for this version number before proceeding to
* decode other parts of this message.
* </pre>
*
* <code>required uint32 version = 15 [default = 1];</code>
*/
public Builder setVersion(int value) {
bitField0_ |= 0x1;
version_ = value;
onChanged();return this;
}
| 3.26 |
graphhopper_VectorTile_addAllKeys_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public Builder addAllKeys(Iterable<String> values) {
ensureKeysIsMutable();
AbstractMessageLite.Builder.addAll(values, keys_);
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_setLayers_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public Builder setLayers(int index, VectorTile.Tile.Layer.Builder builderForValue) {
if (layersBuilder_ == null) {
ensureLayersIsMutable();
layers_.set(index, builderForValue.build());
onChanged();
} else {
layersBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
| 3.26 |
graphhopper_VectorTile_removeLayers_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public Builder removeLayers(int index) {
if (layersBuilder_ == null) {ensureLayersIsMutable();
layers_.remove(index);
onChanged();
} else {
layersBuilder_.remove(index);
}
return this;
}
| 3.26 |
graphhopper_VectorTile_clearGeometry_rdh
|
/**
* <pre>
* Contains a stream of commands and parameters (vertices).
* A detailed description on geometry encoding is located in
* section 4.3 of the specification.
* </pre>
*
* <code>repeated uint32 geometry = 4 [packed = true];</code>
*/
public Builder clearGeometry() {
geometry_ = Collections.emptyList();
bitField0_ = bitField0_ & (~0x8);
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_getFloatValue_rdh
|
/**
* <code>optional float float_value = 2;</code>
*/public float getFloatValue() {
return floatValue_;
}
| 3.26 |
graphhopper_VectorTile_setStringValue_rdh
|
/**
* <pre>
* Exactly one of these values must be present in a valid message
* </pre>
*
* <code>optional string string_value = 1;</code>
*/
public Builder setStringValue(String value) {
if (value == null) {
throw
new NullPointerException();
}
bitField0_ |= 0x1;
stringValue_ = value;
onChanged();
return this;
}
| 3.26 |
graphhopper_VectorTile_getFeaturesList_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public List<VectorTile.Tile.Feature> getFeaturesList() {
if (featuresBuilder_ == null) {
return Collections.unmodifiableList(features_);
} else {
return featuresBuilder_.getMessageList();
}
}
| 3.26 |
graphhopper_VectorTile_getKeysBytes_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public ByteString getKeysBytes(int index) {return keys_.getByteString(index);
}
| 3.26 |
graphhopper_VectorTile_getSintValue_rdh
|
/**
* <code>optional sint64 sint_value = 6;</code>
*/
public long getSintValue() {
return sintValue_;
}
| 3.26 |
graphhopper_VectorTile_m20_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public VectorTile.Tile.Value.Builder m20() {
return getValuesFieldBuilder().addBuilder(VectorTile.Tile.Value.getDefaultInstance());
}
| 3.26 |
graphhopper_VectorTile_getId_rdh
|
/**
* <code>optional uint64 id = 1 [default = 0];</code>
*/
public long
getId() {
return id_;
}
| 3.26 |
graphhopper_VectorTile_getKeysList_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public ProtocolStringList getKeysList() {
return keys_.getUnmodifiableView();
}
| 3.26 |
graphhopper_VectorTile_addAllTags_rdh
|
/**
* <pre>
* Tags of this feature are encoded as repeated pairs of
* integers.
* A detailed description of tags is located in sections
* 4.2 and 4.4 of the specification
* </pre>
*
* <code>repeated uint32 tags = 2 [packed = true];</code>
*/
public Builder addAllTags(Iterable<? extends Integer> values) {
ensureTagsIsMutable();
AbstractMessageLite.Builder.addAll(values, tags_);
onChanged();return
this;
}
| 3.26 |
graphhopper_VectorTile_addAllLayers_rdh
|
/**
* <code>repeated .vector_tile.Tile.Layer layers = 3;</code>
*/
public Builder addAllLayers(Iterable<? extends VectorTile.Tile.Layer> values) {
if (layersBuilder_ ==
null) {
ensureLayersIsMutable();
AbstractMessageLite.Builder.addAll(values, layers_);onChanged();
} else {
layersBuilder_.addAllMessages(values);
}
return this;
}
| 3.26 |
graphhopper_VectorTile_setFeatures_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public Builder setFeatures(int index, VectorTile.Tile.Feature.Builder builderForValue) {
if (featuresBuilder_ == null) {
ensureFeaturesIsMutable();
features_.set(index, builderForValue.build());
onChanged();
} else {
featuresBuilder_.setMessage(index, builderForValue.build());}
return this;
}
| 3.26 |
graphhopper_VectorTile_m19_rdh
|
/**
* <pre>
* Dictionary encoding for values
* </pre>
*
* <code>repeated .vector_tile.Tile.Value values = 4;</code>
*/
public List<VectorTile.Tile.Value> m19() {
if (valuesBuilder_ == null) {
return Collections.unmodifiableList(values_);
} else {
return valuesBuilder_.getMessageList();
}
}
| 3.26 |
graphhopper_VectorTile_getKeys_rdh
|
/**
* <pre>
* Dictionary encoding for keys
* </pre>
*
* <code>repeated string keys = 3;</code>
*/
public String getKeys(int index) {
return keys_.get(index);
}
| 3.26 |
graphhopper_VectorTile_getUintValue_rdh
|
/**
* <code>optional uint64 uint_value = 5;</code>
*/
public long getUintValue() {
return uintValue_;
}
| 3.26 |
graphhopper_VectorTile_removeFeatures_rdh
|
/**
* <pre>
* The actual features in this tile.
* </pre>
*
* <code>repeated .vector_tile.Tile.Feature features = 2;</code>
*/
public Builder removeFeatures(int index) {
if (featuresBuilder_ == null) {
ensureFeaturesIsMutable();
features_.remove(index);
onChanged();
} else {
featuresBuilder_.remove(index);
}
return this;
}
| 3.26 |
graphhopper_VectorTile_m4_rdh
|
/**
* <code>optional sint64 sint_value = 6;</code>
*/
public long m4() {
return sintValue_;
}
| 3.26 |
graphhopper_VectorTile_setExtent_rdh
|
/**
* <pre>
* Although this is an "optional" field it is required by the specification.
* See https://github.com/mapbox/vector-tile-spec/issues/47
* </pre>
*
* <code>optional uint32 extent = 5 [default = 4096];</code>
*/
public Builder setExtent(int value) {
bitField0_ |= 0x20;
extent_ = value;
onChanged();
return this;
}
| 3.26 |
graphhopper_NavigateResponseConverter_getModifier_rdh
|
/**
* No modifier values for arrive and depart
* <p>
* Find modifier values here: https://www.mapbox.com/api-documentation/#stepmaneuver-object
*/
private static String getModifier(Instruction instruction) {
switch (instruction.getSign()) {
case Instruction.CONTINUE_ON_STREET :
return "straight";
case Instruction.U_TURN_LEFT :
case Instruction.U_TURN_RIGHT :
case Instruction.U_TURN_UNKNOWN :
return "uturn";
case Instruction.KEEP_LEFT :
case Instruction.TURN_SLIGHT_LEFT :
return "slight left";
case Instruction.TURN_LEFT :
return "left";
case Instruction.TURN_SHARP_LEFT :
return "sharp left";
case Instruction.KEEP_RIGHT :
case Instruction.TURN_SLIGHT_RIGHT :
return "slight right";
case Instruction.TURN_RIGHT :
return "right";
case Instruction.TURN_SHARP_RIGHT :
return "sharp right";
case Instruction.USE_ROUNDABOUT :
// TODO: This might be an issue in left-handed traffic, because there it schould be left
return "right";
default :
return null;
}
}
| 3.26 |
graphhopper_NavigateResponseConverter_convertFromGHResponse_rdh
|
/**
* Converts a GHResponse into a json that follows the Mapbox API specification
*/
public static ObjectNode convertFromGHResponse(GHResponse ghResponse, TranslationMap translationMap, Locale locale, DistanceConfig distanceConfig) {
ObjectNode json = JsonNodeFactory.instance.objectNode();
if (ghResponse.hasErrors())
throw new IllegalStateException("If the response has errors, you should use the method NavigateResponseConverter#convertFromGHResponseError");
PointList waypoints
=
ghResponse.getBest().getWaypoints();
final ArrayNode routesJson = json.putArray("routes");
List<ResponsePath>
paths = ghResponse.getAll();
for (int i = 0; i < paths.size(); i++) {
ResponsePath path = paths.get(i);
ObjectNode pathJson = routesJson.addObject();
putRouteInformation(pathJson, path, i, translationMap, locale, distanceConfig);
}
final ArrayNode waypointsJson = json.putArray("waypoints");
for (int i = 0; i < waypoints.size(); i++) {
ObjectNode waypointJson = waypointsJson.addObject();
// TODO get names
waypointJson.put("name", "");
putLocation(waypoints.getLat(i), waypoints.getLon(i), waypointJson);
}
json.put("code", "Ok");
// TODO: Maybe we need a different format... uuid: "cji4ja4f8004o6xrsta8w4p4h"
json.put("uuid", UUID.randomUUID().toString().replaceAll("-", ""));
return json;
}
| 3.26 |
graphhopper_NavigateResponseConverter_putLocation_rdh
|
/**
* Puts a location array in GeoJson format into the node
*/
private static ObjectNode putLocation(double lat, double lon, ObjectNode node) {
ArrayNode location = node.putArray("location");
// GeoJson lon,lat
location.add(Helper.round6(lon));
location.add(Helper.round6(lat));
return node;
}
| 3.26 |
graphhopper_NavigateResponseConverter_putBannerInstructions_rdh
|
/**
* Banner instructions are the turn instructions that are shown to the user in the top bar.
* <p>
* Between two instructions we can show multiple banner instructions, you can control when they pop up using distanceAlongGeometry.
*/
private static void putBannerInstructions(InstructionList instructions, double distance, int index, Locale locale, TranslationMap translationMap, ArrayNode bannerInstructions) {
/* A BannerInstruction looks like this
distanceAlongGeometry: 107,
primary: {
text: "Lichtensteinstraße",
components: [
{
text: "Lichtensteinstraße",
type: "text",
}
],
type: "turn",
modifier: "right",
},
secondary: null,
*/
ObjectNode bannerInstruction = bannerInstructions.addObject();
// Show from the beginning
bannerInstruction.put("distanceAlongGeometry", distance);
ObjectNode primary = bannerInstruction.putObject("primary");
putSingleBannerInstruction(instructions.get(index + 1), locale, translationMap, primary);
bannerInstruction.putNull("secondary");
if ((instructions.size() > (index + 2)) && (instructions.get(index + 2).getSign() != Instruction.REACHED_VIA)) {
// Sub shows the instruction after the current one
ObjectNode sub = bannerInstruction.putObject("sub");
putSingleBannerInstruction(instructions.get(index + 2), locale, translationMap, sub);
}
}
| 3.26 |
graphhopper_NavigateResponseConverter_getTurnType_rdh
|
/**
* Relevant maneuver types are:
* depart (firs instruction)
* turn (regular turns)
* roundabout (enter roundabout, maneuver contains also the exit number)
* arrive (last instruction and waypoints)
* <p>
* You can find all maneuver types at: https://www.mapbox.com/api-documentation/#maneuver-types
*/
private static String getTurnType(Instruction instruction, boolean isFirstInstructionOfLeg) {
if (isFirstInstructionOfLeg) {
return "depart";
} else {
switch (instruction.getSign()) {
case
Instruction.FINISH :
case Instruction.REACHED_VIA :
return "arrive";
case Instruction.USE_ROUNDABOUT :
return "roundabout";
default :
return "turn";
}
}
}
| 3.26 |
graphhopper_NavigateResponseConverter_getThenVoiceInstructionpart_rdh
|
/**
* For close turns, it is important to announce the next turn in the earlier instruction.
* e.g.: instruction i+1= turn right, instruction i+2=turn left, with instruction i+1 distance < VOICE_INSTRUCTION_MERGE_TRESHHOLD
* The voice instruction should be like "turn right, then turn left"
* <p>
* For instruction i+1 distance > VOICE_INSTRUCTION_MERGE_TRESHHOLD an empty String will be returned
*/
private static String getThenVoiceInstructionpart(InstructionList instructions, int index, Locale locale, TranslationMap translationMap) {
if (instructions.size() > (index + 2)) {
Instruction firstInstruction = instructions.get(index + 1);
if (firstInstruction.getDistance() < VOICE_INSTRUCTION_MERGE_TRESHHOLD) {
Instruction secondInstruction = instructions.get(index + 2);
if (secondInstruction.getSign() != Instruction.REACHED_VIA)
return ((", " + translationMap.getWithFallBack(locale).tr("navigate.then")) + " ") + secondInstruction.getTurnDescription(translationMap.getWithFallBack(locale));
}
}
return "";
}
| 3.26 |
graphhopper_DepthFirstSearch_start_rdh
|
/**
* beginning with startNode add all following nodes to LIFO queue. If node has been already
* explored before, skip reexploration.
*/
@Override
public void start(EdgeExplorer explorer, int startNode) {
IntArrayDeque stack = new IntArrayDeque();
GHBitSet explored = createBitSet();
stack.addLast(startNode);
int current;
while (stack.size() > 0) {
current = stack.removeLast();
if ((!explored.contains(current))
&& goFurther(current)) {
EdgeIterator iter = explorer.setBaseNode(current);
while (iter.next()) {
int
connectedId = iter.getAdjNode();
if (checkAdjacent(iter)) {
stack.addLast(connectedId);
}
}
explored.add(current);
}
}
}
| 3.26 |
graphhopper_AbstractTiffElevationProvider_downloadToFile_rdh
|
/**
* Download a file at the provided url and save it as the given downloadFile if the downloadFile does not exist.
*/
private void downloadToFile(File downloadFile, String url) throws IOException {
if (!downloadFile.exists()) {
int max = 3;
for (int trial = 0; trial < max; trial++) {
try {
downloader.downloadFile(url, downloadFile.getAbsolutePath());
return;
} catch (SocketTimeoutException ex) {
if (trial >= (max - 1))throw new RuntimeException(ex);
try {
Thread.sleep(sleep);
} catch (InterruptedException ignored) {}
}
}
}
}
| 3.26 |
graphhopper_CustomModelParser_injectStatements_rdh
|
/**
* Injects the already parsed expressions (converted to BlockStatement) via Janino's DeepCopier to the provided
* CompilationUnit cu (a class file).
*/
private static CompilationUnit injectStatements(List<Java.BlockStatement> priorityStatements, List<Java.BlockStatement> speedStatements, Java.CompilationUnit cu) throws CompileException {
cu = new DeepCopier() {
boolean speedInjected = false;
boolean priorityInjected = false;
@Override
public MethodDeclarator copyMethodDeclarator(Java.MethodDeclarator subject) throws CompileException {
if ((subject.name.equals("getSpeed") && (!speedStatements.isEmpty())) && (!speedInjected)) {
speedInjected = true;
return injectStatements(subject, this, speedStatements);
} else if ((subject.name.equals("getPriority") && (!priorityStatements.isEmpty())) && (!priorityInjected)) {
priorityInjected = true;
return injectStatements(subject, this, priorityStatements);
} else {
return super.copyMethodDeclarator(subject);
}
}
}.copyCompilationUnit(cu);
return cu;
}
| 3.26 |
graphhopper_CustomModelParser_createClassTemplate_rdh
|
/**
* Create the class source file from the detected variables (priorityVariables and speedVariables). We assume that
* these variables are safe although they are user input because we collected them from parsing via Janino. This
* means that the source file is free from user input and could be directly compiled. Before we do this we still
* have to inject that parsed and safe user expressions in a later step.
*/
private static String createClassTemplate(long counter, Set<String> priorityVariables, double maxPriority, Set<String>
speedVariables, double maxSpeed, EncodedValueLookup lookup, Map<String, JsonFeature> areas) {final StringBuilder importSourceCode = new StringBuilder("import com.graphhopper.routing.ev.*;\n");
importSourceCode.append("import java.util.Map;\n");
final StringBuilder classSourceCode = new StringBuilder(100);
boolean includedAreaImports = false;
final StringBuilder initSourceCode = new StringBuilder("this.avg_speed_enc = avgSpeedEnc;\n");
initSourceCode.append("this.priority_enc = priorityEnc;\n");
Set<String> set = new HashSet<>();
for (String prioVar : priorityVariables)
set.add(prioVar.startsWith(BACKWARD_PREFIX) ? prioVar.substring(BACKWARD_PREFIX.length()) : prioVar);
for (String speedVar : speedVariables)
set.add(speedVar.startsWith(BACKWARD_PREFIX) ? speedVar.substring(BACKWARD_PREFIX.length()) : speedVar);
for (String arg : set) {
if (lookup.hasEncodedValue(arg)) {
EncodedValue enc = lookup.getEncodedValue(arg, EncodedValue.class);
classSourceCode.append(((("protected " + getInterface(enc)) + " ") + arg) + "_enc;\n");
initSourceCode.append(((((("this." + arg) + "_enc = (") + getInterface(enc)) + ") lookup.getEncodedValue(\"") + arg) + "\", EncodedValue.class);\n");} else if
(arg.startsWith(IN_AREA_PREFIX)) {
if (!includedAreaImports) {
importSourceCode.append(("import " + BBox.class.getName()) + ";\n");
importSourceCode.append(("import " + GHUtility.class.getName()) + ";\n");
importSourceCode.append(("import " + PreparedPolygon.class.getName())
+ ";\n");
importSourceCode.append(("import " + Polygonal.class.getName()) + ";\n");
importSourceCode.append(("import " + JsonFeature.class.getName()) + ";\n");
importSourceCode.append(("import " + Polygon.class.getName()) + ";\n");
includedAreaImports = true;
}
if (!JsonFeature.isValidId(arg))
throw new IllegalArgumentException("Area has invalid name: " + arg);
String id = arg.substring(IN_AREA_PREFIX.length());
JsonFeature feature = areas.get(id);
if (feature == null)
throw new IllegalArgumentException(("Area '" + id) + "' wasn't found");
if (feature.getGeometry() == null)
throw new IllegalArgumentException(("Area '"
+ id) + "' does not contain a geometry");
if (!(feature.getGeometry() instanceof Polygonal))
throw new IllegalArgumentException("Currently only type=Polygon is supported for areas but was " + feature.getGeometry().getGeometryType());
if (feature.getBBox() != null)
throw new IllegalArgumentException(("Bounding box of area " + id) + " must be empty");
classSourceCode.append(((("protected " + Polygon.class.getSimpleName()) + " ") + arg) + ";\n");
initSourceCode.append(((("JsonFeature feature_" + id) + " = (JsonFeature) areas.get(\"") + id) + "\");\n");
initSourceCode.append(((("this." + arg) + " = new Polygon(new PreparedPolygon((Polygonal) feature_") +
id) + ".getGeometry()));\n");
} else if (!arg.startsWith(IN_AREA_PREFIX))
throw new IllegalArgumentException("Variable not supported: " + arg);
}
return ((((((((((((((((((((((((((((((((((((((((((((((("" + "package com.graphhopper.routing.weighting.custom;\n") + "import ") + CustomWeightingHelper.class.getName()) + ";\n") + "import ") + EncodedValueLookup.class.getName()) + ";\n") + "import ") + EdgeIteratorState.class.getName()) + ";\n") + importSourceCode) + "\npublic class JaninoCustomWeightingHelperSubclass") + counter) + " extends ") + CustomWeightingHelper.class.getSimpleName()) + " {\n") + classSourceCode) + " @Override\n") + " public void init(EncodedValueLookup lookup, ") + DecimalEncodedValue.class.getName()) + " avgSpeedEnc, ") + DecimalEncodedValue.class.getName()) + " priorityEnc, Map<String, ") + JsonFeature.class.getName()) + "> areas) {\n") + initSourceCode) + " }\n\n") + // we need these placeholder methods so that the hooks in DeepCopier are invoked
" @Override\n") + " public double getPriority(EdgeIteratorState edge, boolean reverse) {\n") + " return 1; //will be overwritten by code injected in DeepCopier\n") + " }\n") + " @Override\n") + " public double getSpeed(EdgeIteratorState edge, boolean reverse) {\n") + " return getRawSpeed(edge, reverse); //will be overwritten by code injected in DeepCopier\n") + " }\n") + " @Override\n") + " protected double getMaxSpeed() {\n") + " return ") + maxSpeed) + ";") + " }\n") + " @Override\n") + " protected double getMaxPriority() {\n") + " return ") + maxPriority) + ";") + " }\n") + "}"; }
| 3.26 |
graphhopper_CustomModelParser_createGetSpeedStatements_rdh
|
/**
* Parse the expressions from CustomModel relevant for the method getSpeed - see createClassTemplate.
*
* @return the created statements (parsed expressions)
*/
private static List<Java.BlockStatement> createGetSpeedStatements(Set<String> speedVariables, CustomModel customModel, EncodedValueLookup lookup) throws Exception {
List<Java.BlockStatement> speedStatements = new ArrayList<>(verifyExpressions(new StringBuilder(), "speed entry", speedVariables, customModel.getSpeed(), lookup));
String speedMethodStartBlock =
"double value = super.getRawSpeed(edge, reverse);\n";
// a bit inefficient to possibly define variables twice, but for now we have two separate methods
for (String arg : speedVariables) {
speedMethodStartBlock += getVariableDeclaration(lookup, arg);
}
speedStatements.addAll(0, new Parser(new Scanner("getSpeed", new StringReader(speedMethodStartBlock))).parseBlockStatements());
return speedStatements;
}
| 3.26 |
graphhopper_CustomModelParser_verifyExpressions_rdh
|
/**
* This method does:
* 1. check user expressions via Parser.parseConditionalExpression and only allow whitelisted variables and methods.
* 2. while this check it also guesses the variable names and stores it in createObjects
* 3. creates if-then-elseif expressions from the checks and returns them as BlockStatements
*
* @return the created if-then, else and elseif statements
*/
private static List<Java.BlockStatement> verifyExpressions(StringBuilder expressions, String info, Set<String> createObjects, List<Statement> list, EncodedValueLookup lookup) throws Exception {
// allow variables, all encoded values, constants and special variables like in_xyarea or backward_car_access
NameValidator nameInConditionValidator = name -> ((lookup.hasEncodedValue(name) || name.toUpperCase(Locale.ROOT).equals(name)) || name.startsWith(IN_AREA_PREFIX)) || (name.startsWith(BACKWARD_PREFIX) && lookup.hasEncodedValue(name.substring(BACKWARD_PREFIX.length())));
parseExpressions(expressions, nameInConditionValidator, info, createObjects, list);
return new Parser(new Scanner(info, new StringReader(expressions.toString()))).parseBlockStatements();
}
| 3.26 |
graphhopper_CustomModelParser_getVariableDeclaration_rdh
|
/**
* For the methods getSpeed and getPriority we declare variables that contain the encoded value of the current edge
* or if an area contains the current edge.
*/private static String getVariableDeclaration(EncodedValueLookup lookup, final String arg) {
if (lookup.hasEncodedValue(arg)) {
EncodedValue enc = lookup.getEncodedValue(arg, EncodedValue.class);
return ((((((((((((((getReturnType(enc) + " ") + arg) + " = (") + getReturnType(enc)) + ") (reverse ? ") +
"edge.getReverse((") + getInterface(enc)) + ") this.") + arg) + "_enc) : ") + "edge.get((") + getInterface(enc)) + ") this.") + arg) + "_enc));\n";
} else if (arg.startsWith(BACKWARD_PREFIX)) {
final String argSubstr = arg.substring(BACKWARD_PREFIX.length());
if (lookup.hasEncodedValue(argSubstr)) {
EncodedValue enc = lookup.getEncodedValue(argSubstr, EncodedValue.class);
return ((((((((((((((getReturnType(enc) + " ") + arg) + " = (") + getReturnType(enc)) + ") (reverse ? ") + "edge.get((") + getInterface(enc)) + ") this.") + argSubstr) + "_enc) : ") + "edge.getReverse((") + getInterface(enc)) + ") this.") + argSubstr) + "_enc));\n";
} else {throw new IllegalArgumentException("Not supported for backward: " + argSubstr);
}
} else if (arg.startsWith(IN_AREA_PREFIX)) {
return "";
} else {
throw new IllegalArgumentException("Not supported " + arg);
}
}
| 3.26 |
graphhopper_CustomModelParser_createWeightingParameters_rdh
|
/**
* This method compiles a new subclass of CustomWeightingHelper composed from the provided CustomModel caches this
* and returns an instance.
*
* @param priorityEnc
* can be null
*/
public static Parameters createWeightingParameters(CustomModel customModel, EncodedValueLookup lookup, DecimalEncodedValue avgSpeedEnc, double globalMaxSpeed, DecimalEncodedValue priorityEnc) {
double globalMaxPriority = (priorityEnc == null) ? 1 : priorityEnc.getMaxStorableDecimal();
// if the same custom model is used with a different base profile we cannot use the cached version
String key = ((((customModel + ",speed:") + avgSpeedEnc.getName()) + ",global_max_speed:") + globalMaxSpeed) + (priorityEnc == null ? "" : (("prio:" + priorityEnc.getName()) + ",global_max_priority:")
+ globalMaxPriority);if (key.length() > 100000)
throw new IllegalArgumentException("Custom Model too big: " + key.length());
Class<?> clazz = (customModel.isInternal()) ? INTERNAL_CACHE.get(key) : null;
if ((CACHE_SIZE > 0) && (clazz == null))
clazz = CACHE.get(key);
if (clazz == null) {
clazz = createClazz(customModel, lookup, globalMaxSpeed, globalMaxPriority);
if (customModel.isInternal()) {
INTERNAL_CACHE.put(key, clazz);
if (INTERNAL_CACHE.size() > 100) {CACHE.putAll(INTERNAL_CACHE);
INTERNAL_CACHE.clear();
LoggerFactory.getLogger(CustomModelParser.class).warn(("Internal cache must stay small but was " + INTERNAL_CACHE.size()) + ". Cleared it. Misuse of CustomModel::internal?");
}
} else if (CACHE_SIZE > 0) {
CACHE.put(key, clazz);
}
}
try {
// The class does not need to be thread-safe as we create an instance per request
CustomWeightingHelper prio = ((CustomWeightingHelper) (clazz.getDeclaredConstructor().newInstance()));
prio.init(lookup, avgSpeedEnc, priorityEnc, CustomModel.getAreasAsMap(customModel.getAreas()));
return new CustomWeighting.Parameters(prio::getSpeed, prio::getPriority, prio.getMaxSpeed(), prio.getMaxPriority(), customModel.getDistanceInfluence() == null ? 0 : customModel.getDistanceInfluence(), customModel.getHeadingPenalty() == null ? Routing.DEFAULT_HEADING_PENALTY : customModel.getHeadingPenalty());
} catch (ReflectiveOperationException ex) {
throw new IllegalArgumentException("Cannot compile expression " + ex.getMessage(), ex);
}
}
| 3.26 |
graphhopper_CustomModelParser_createGetPriorityStatements_rdh
|
/**
* Parse the expressions from CustomModel relevant for the method getPriority - see createClassTemplate.
*
* @return the created statements (parsed expressions)
*/
private static List<Java.BlockStatement>
createGetPriorityStatements(Set<String>
priorityVariables, CustomModel customModel, EncodedValueLookup lookup) throws Exception {
List<Java.BlockStatement> priorityStatements = new ArrayList<>(verifyExpressions(new StringBuilder(), "priority entry", priorityVariables, customModel.getPriority(), lookup));
String priorityMethodStartBlock = "double value = super.getRawPriority(edge, reverse);\n";
for (String arg : priorityVariables) {
priorityMethodStartBlock += getVariableDeclaration(lookup, arg);
}
priorityStatements.addAll(0, new Parser(new Scanner("getPriority", new StringReader(priorityMethodStartBlock))).parseBlockStatements());
return priorityStatements;
}
| 3.26 |
graphhopper_ReaderElement_m0_rdh
|
/**
* Returns the first existing tag of the specified list where the order is important.
*
* @return an empty string if nothing found
*/
public String m0(List<String> restrictions) {
for (String str : restrictions) {
Object value = properties.get(str);
if (value != null)
return ((String) (value));
}
return "";
}
| 3.26 |
graphhopper_ReaderElement_hasTag_rdh
|
/**
* Check a number of tags in the given order if their value is equal to the specified value.
*/
public boolean hasTag(List<String> keyList, Object value) {
for (String key : keyList) {
if (value.equals(getTag(key, null)))
return true;
}
return false;
}
| 3.26 |
graphhopper_HeadingExample_createGraphHopperInstance_rdh
|
/**
* See {@link RoutingExample#createGraphHopperInstance} for more comments on creating the GraphHopper instance.
*/
static GraphHopper createGraphHopperInstance(String ghLoc)
{
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile(ghLoc);
hopper.setGraphHopperLocation("target/heading-graph-cache");
hopper.setProfiles(new Profile("car").setCustomModel(new CustomModel().addToPriority(If("road_access == DESTINATION", MULTIPLY, "0.1"))).setVehicle("car").setTurnCosts(false));
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile("car"));
hopper.importOrLoad();
return hopper;
}
| 3.26 |
graphhopper_SubnetworkStorage_getSubnetwork_rdh
|
/**
* Returns the subnetwork ID for the specified nodeId or 0 if non is associated e.g. because the
* subnetwork is too small.
*/
public int getSubnetwork(int nodeId) {
return da.getByte(nodeId);
}
| 3.26 |
graphhopper_SubnetworkStorage_setSubnetwork_rdh
|
/**
* This method sets the subnetwork if of the specified nodeId. Default is 0 and means subnetwork
* was too small to be useful to be stored.
*/
public void setSubnetwork(int nodeId, int subnetwork)
{
if (subnetwork > 127)
throw new IllegalArgumentException("Number of subnetworks is currently limited to 127 but requested " + subnetwork);
da.setByte(nodeId, ((byte) (subnetwork)));
}
| 3.26 |
graphhopper_ResponsePathDeserializer_toMap_rdh
|
// Credits to: http://stackoverflow.com/a/24012023/194609
private static Map<String, Object> toMap(ObjectMapper objectMapper, JsonNode object) {return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {});
}
| 3.26 |
graphhopper_MaxSpeedCalculator_fillMaxSpeed_rdh
|
/**
* This method sets max_speed values where the value is UNSET_SPEED to a value determined by
* the default speed library which is country-dependent.
*/
public void fillMaxSpeed(Graph graph, EncodingManager em) {
// In DefaultMaxSpeedParser and in OSMMaxSpeedParser we don't have the rural/urban info,
// but now we have and can fill the country-dependent max_speed value where missing.
EnumEncodedValue<UrbanDensity> udEnc = em.getEnumEncodedValue(UrbanDensity.KEY, UrbanDensity.class);
fillMaxSpeed(graph, em, edge -> edge.get(udEnc) != UrbanDensity.RURAL);
}
| 3.26 |
graphhopper_MaxSpeedCalculator_createMaxSpeedStorage_rdh
|
/**
* Creates temporary uni dir max_speed storage that is removed after import.
*/
private EdgeIntAccess createMaxSpeedStorage(DataAccess dataAccess) {return new EdgeIntAccess() {
public int getInt(int edgeId, int index) {
dataAccess.ensureCapacity((edgeId * 2L) + 2L);
return dataAccess.getShort(edgeId * 2L);
}
public void setInt(int edgeId, int index, int value) {
dataAccess.ensureCapacity((edgeId * 2L) + 2L);
if (value > Short.MAX_VALUE)
throw new IllegalStateException("value too large for short: " + value);
dataAccess.setShort(edgeId * 2L, ((short) (value)));
}
};
}
| 3.26 |
graphhopper_ResponsePath_addPathDetails_rdh
|
/**
* Adds the given PathDetails to the existing ones. If there are already PathDetails set, the number
* details has to be equal to <code>details</code>.
*
* @param details
* The PathDetails to add
*/
public void addPathDetails(Map<String, List<PathDetail>> details) {
if (((!this.pathDetails.isEmpty()) && (!details.isEmpty())) && (this.pathDetails.size() != details.size())) {
throw new IllegalStateException("Details have to be the same size");
}
for (Map.Entry<String, List<PathDetail>> detailEntry : details.entrySet()) {
String key = detailEntry.getKey();
if (this.pathDetails.containsKey(key)) {
this.pathDetails.get(key).addAll(detailEntry.getValue());
} else {
this.pathDetails.put(key, detailEntry.getValue());
}
}
}
| 3.26 |
graphhopper_ResponsePath_calcBBox2D_rdh
|
/**
* Calculates the 2D bounding box of this route
*/public Envelope calcBBox2D() {
check("calcBBox2D");
Envelope bounds = new Envelope();
for (int i = 0; i < pointList.size();
i++) {
bounds.expandToInclude(pointList.getLon(i), pointList.getLat(i));
}
return bounds;
}
| 3.26 |
graphhopper_ResponsePath_getTime_rdh
|
/**
*
* @return time in millis
*/
public long getTime() {
check("getTimes");
return time;
}
| 3.26 |
graphhopper_ResponsePath_getWaypoints_rdh
|
/**
* This method returns the input points snapped to the road network.
*/
public PointList getWaypoints() {
check("getWaypoints");
return waypointList;
}
| 3.26 |
graphhopper_ResponsePath_getDescend_rdh
|
/**
* This method returns the total elevation change (going downwards) in meter.
* <p>
*
* @return decline in meter
*/
public double getDescend() {
return descend;
}
| 3.26 |
graphhopper_ResponsePath_getRouteWeight_rdh
|
/**
* This method returns a double value which is better than the time for comparison of routes but
* only if you know what you are doing, e.g. only to compare routes gained with the same query
* parameters like vehicle.
*/
public double getRouteWeight() {
check("getRouteWeight");
return f0;
}
| 3.26 |
graphhopper_ResponsePath_getAscend_rdh
|
/**
* This method returns the total elevation change (going upwards) in meter.
* <p>
*
* @return ascend in meter
*/ public double getAscend() {
return ascend;
}
| 3.26 |
graphhopper_ResponsePath_getPoints_rdh
|
/**
* This method returns all points on the path. Keep in mind that calculating the distance from
* these points might yield different results compared to getDistance as points could have been
* simplified on import or after querying.
*/
public PointList getPoints() {
check("getPoints");
return pointList;
}
| 3.26 |
graphhopper_EncodedValue_next_rdh
|
/**
* This method determines a space of the specified bits and sets shift and dataIndex accordingly
*/
void next(int usedBits) {
shift = nextShift;if ((((shift - 1) + usedBits) / 32) > ((shift - 1) / 32)) {
dataIndex++;
shift = 0;
}
// we need 1L as otherwise it'll fail for usedBits==32
bitMask = ((int) ((1L << usedBits) - 1));
bitMask <<= shift;
nextShift = shift + usedBits;
}
| 3.26 |
graphhopper_TraversalMode_createTraversalId_rdh
|
/**
* Returns the identifier to access the map of the shortest path tree according to the traversal
* mode. E.g. returning the adjacent node id in node-based behavior whilst returning the edge id
* in edge-based behavior
* <p>
*
* @param edgeState
* the current {@link EdgeIteratorState}
* @param reverse
* <code>true</code>, if traversal in backward direction. Will be true only for
* backward searches in bidirectional algorithms.
* @return the identifier to access the shortest path tree
*/
public final int createTraversalId(EdgeIteratorState edgeState, boolean reverse) {
if (edgeBased)
return reverse ? edgeState.getReverseEdgeKey() : edgeState.getEdgeKey();
return edgeState.getAdjNode();}
| 3.26 |
graphhopper_RestrictionConverter_convert_rdh
|
/**
* OSM restriction relations specify turn restrictions between OSM ways (of course). This method converts such a
* relation into a 'graph' representation, where the turn restrictions are specified in terms of edge/node IDs instead
* of OSM IDs.
*
* @throws OSMRestrictionException
* if the given relation is either not valid in some way and/or cannot be handled and
* shall be ignored
*/
public static Triple<ReaderRelation, GraphRestriction, RestrictionMembers> convert(ReaderRelation relation, BaseGraph baseGraph, LongFunction<Iterator<IntCursor>> edgesByWay)
throws OSMRestrictionException {
if (!isTurnRestriction(relation))
throw new IllegalArgumentException("expected a turn restriction: " + relation.getTags());
RestrictionMembers restrictionMembers = extractMembers(relation);
if (!membersExist(restrictionMembers, edgesByWay, relation))throw OSMRestrictionException.withoutWarning();
// every OSM way might be split into *multiple* edges, so now we need to figure out which edges are the ones
// that are actually part of the given relation
WayToEdgeConverter wayToEdgeConverter = new WayToEdgeConverter(baseGraph, edgesByWay);
if (restrictionMembers.isViaWay()) {
WayToEdgeConverter.EdgeResult res =
wayToEdgeConverter.convertForViaWays(restrictionMembers.getFromWays(), restrictionMembers.getViaWays(), restrictionMembers.getToWays());
return new Triple<>(relation, GraphRestriction.way(res.getFromEdges(), res.getViaEdges(), res.getToEdges(), res.getNodes()), restrictionMembers);
} else {
int viaNode = relation.getTag("graphhopper:via_node", -1);
if (viaNode < 0)
throw new IllegalStateException("For some reason we did not set graphhopper:via_node for this relation: " + relation.getId());
WayToEdgeConverter.NodeResult res = wayToEdgeConverter.convertForViaNode(restrictionMembers.getFromWays(), viaNode, restrictionMembers.getToWays());
return new Triple<>(relation, GraphRestriction.node(res.getFromEdges(), viaNode, res.getToEdges()), restrictionMembers);
}
}
| 3.26 |
graphhopper_GHRequest_setAlgorithm_rdh
|
/**
* For possible values see AlgorithmOptions.*
*/
public GHRequest setAlgorithm(String algo) {
if (algo != null)
this.algo
= Helper.camelCaseToUnderScore(algo);
return this;
}
| 3.26 |
graphhopper_GHRequest_putHint_rdh
|
/**
* This method sets a key value pair in the hints and is unrelated to the setPointHints method.
* It is mainly used for deserialization with Jackson.
*
* @see #setPointHints(List)
*/
// a good trick to serialize unknown properties into the HintsMap
@JsonAnySetter
public GHRequest putHint(String
fieldName, Object value) {
this.hints.putObject(fieldName, value);
return this;
}
| 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.