name stringlengths 12 178 | code_snippet stringlengths 8 36.5k | score float64 3.26 3.68 |
|---|---|---|
graphhopper_GHRequest_setHeadings_rdh | /**
* Sets the headings, i.e. the direction the route should leave the starting point and the directions the route
* should arrive from at the via-points and the end point. Each heading is given as north based azimuth (clockwise)
* in [0, 360) or NaN if no direction shall be specified.
* <p>
* The number of headin... | 3.26 |
graphhopper_Unzipper_getVerifiedFile_rdh | // see #1628
File getVerifiedFile(File destinationDir, ZipEntry ze) throws IOException {
File destinationFile = new File(destinationDir, ze.getName());
if (!destinationFile.getCanonicalPath().startsWith(destinationDir.getCanonicalPath() + File.separator))
throw new SecurityException("Zip Entry is outsi... | 3.26 |
graphhopper_Unzipper_unzip_rdh | /**
*
* @param progressListener
* updates not in percentage but the number of bytes already read.
*/
public void unzip(InputStream fromIs, File toFolder, LongConsumer progressListener) throws IOException {
if (!toFolder.exists())
toFolder.mkdirs();
long sumBytes = 0;
ZipInputStream zis = new ... | 3.26 |
graphhopper_AStarBidirectionCH_setApproximation_rdh | /**
*
* @param approx
* if true it enables approximate distance calculation from lat,lon values
*/
public AStarBidirectionCH setApproximation(WeightApproximator approx) {
weightApprox = new BalancedWeightApproximator(approx);
return this;
} | 3.26 |
graphhopper_RoutingExampleTC_createGraphHopperInstance_rdh | // see RoutingExample for more details
static GraphHopper createGraphHopperInstance(String ghLoc) {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile(ghLoc);
hopper.setGraphHopperLocation("target/routing-tc-graph-cache");
Profile profile = // we can also set u_turn_costs (in seconds). by default... | 3.26 |
graphhopper_ShortestPathTree_setDistanceLimit_rdh | /**
* Distance limit in meter
*/
public void setDistanceLimit(double limit) {
exploreType = DISTANCE;
this.limit = limit;
this.queueByZ = new PriorityQueue<>(1000, comparingDouble(l -> l.distance));
} | 3.26 |
graphhopper_ShortestPathTree_setTimeLimit_rdh | /**
* Time limit in milliseconds
*/
public void setTimeLimit(double limit) {
exploreType = f0;
this.limit = limit;
this.queueByZ = new PriorityQueue<>(1000, comparingLong(l -> l.time));
} | 3.26 |
graphhopper_NodeBasedWitnessPathSearcher_getMemoryUsageAsString_rdh | /**
*
* @return currently used memory in MB (approximately)
*/
public String getMemoryUsageAsString() {
return ((((8L * weights.length) + (changedNodes.buffer.length * 4L)) + heap.getMemoryUsage()) / Helper.MB) + "MB";
} | 3.26 |
graphhopper_NodeBasedWitnessPathSearcher_findUpperBound_rdh | /**
* Runs or continues a Dijkstra search starting at the startNode and ignoring the ignoreNode given in init().
* If the shortest path is found we return its weight. However, this method also returns early if any path was
* found for which the weight is below or equal to the given acceptedWeight, or the given maxim... | 3.26 |
graphhopper_OSMMaxSpeedParser_isValidSpeed_rdh | /**
*
* @return <i>true</i> if the given speed is not {@link Double#NaN}
*/
private boolean isValidSpeed(double speed) {
return !Double.isNaN(speed);
} | 3.26 |
graphhopper_GraphHopperGeocoding_geocode_rdh | /**
* Perform a geocoding request. Both forward and revers are possible, just configure the <code>request</code>
* accordingly.
*
* @param request
* the request to send to the API
* @return found results for your request
*/
public GHGeocodingResponse geocode(GHGeocodingRequest request) {
String url = build... | 3.26 |
graphhopper_AbstractSRTMElevationProvider_calcIntKey_rdh | // use int key instead of string for lower memory usage
int calcIntKey(double lat, double lon) {
// we could use LinearKeyAlgo but this is simpler as we only need integer precision:
return (((down(lat) + 90) * 1000) + down(lon)) + 180;
} | 3.26 |
graphhopper_AbstractSRTMElevationProvider_toShort_rdh | // we need big endianess to read the SRTM files
final short toShort(byte[] b, int offset) {
return ((short) (((b[offset] & 0xff) << 8) | (b[offset + 1] & 0xff)));
} | 3.26 |
graphhopper_VectorTileDecoder_setAutoScale_rdh | /**
* Set the autoScale setting.
*
* @param autoScale
* when true, the encoder automatically scale and return all coordinates in the 0..255 range.
* when false, the encoder returns all coordinates in the 0..extent-1 range as they are encoded.
*/
public void setAutoScale(boolean autoScale) {
this.autoScale... | 3.26 |
graphhopper_VectorTileDecoder_isAutoScale_rdh | /**
* Get the autoScale setting.
*
* @return autoScale
*/
public boolean isAutoScale() {
return autoScale;
} | 3.26 |
graphhopper_GHPoint_toGeoJson_rdh | /**
* Attention: geoJson is LON,LAT
*/
public Double[] toGeoJson() {
return new Double[]{ lon, lat
};
} | 3.26 |
graphhopper_JaroWinkler_distance_rdh | /**
* Return 1 - similarity.
*/
public final double distance(final String s1, final String s2) {
return 1.0 - m0(s1, s2);
} | 3.26 |
graphhopper_JaroWinkler_getThreshold_rdh | /**
* Returns the current value of the threshold used for adding the Winkler
* bonus. The default value is 0.7.
*
* @return the current value of the threshold
*/
public final double getThreshold() {
return f0;
} | 3.26 |
graphhopper_JaroWinkler_m0_rdh | /**
* Compute JW similarity.
*/
public final double m0(final String s1, final String s2) {
int[] mtp = matches(s1, s2);
float m = mtp[0];
if (m == 0) {
return 0.0F;
} double j = (((m / s1.length()) + (m / s2.length())) + ((m - mtp[1]) / m)) / THREE;
double jw = j;
if (j > getThresh... | 3.26 |
graphhopper_TileBasedElevationProvider_setInterpolate_rdh | /**
* Configuration option to use bilinear interpolation to find the elevation at a point from the
* surrounding elevation points. Has only an effect if called before the first getEle call.
* Turned off by default.
*/
public TileBasedElevationProvider setInterpolate(boolean interpolate)
{
this.interpolate = int... | 3.26 |
graphhopper_TileBasedElevationProvider_setBaseURL_rdh | /**
* Specifies the service URL where to download the elevation data. An empty string should set it
* to the default URL. Default is a provider-dependent URL which should work out of the box.
*/
public TileBasedElevationProvider setBaseURL(String baseUrl) {
if ((baseUrl == null) || baseUrl.isEmpty())
throw n... | 3.26 |
graphhopper_PbfDecoder_waitForUpdate_rdh | /**
* Any thread can call this method when they wish to wait until an update has been performed by
* another thread.
*/
private void waitForUpdate() {
try {
dataWaitCondition.await();
} catch (InterruptedException e) {
throw new RuntimeException("Thread was interrupted.", e);
}
} | 3.26 |
graphhopper_PbfDecoder_m0_rdh | /**
* Any thread can call this method when they wish to signal another thread that an update has
* occurred.
*/
private void m0() {
dataWaitCondition.signal();
} | 3.26 |
graphhopper_NodeBasedNodeContractor_insertShortcuts_rdh | /**
* Calls the shortcut handler for all edges and shortcuts adjacent to the given node. After this method is called
* these edges and shortcuts will be removed from the prepare graph, so this method offers the last chance to deal
* with them.
*/
private void insertShortcuts(int node) {
shortcuts.clear();
i... | 3.26 |
graphhopper_NodeBasedNodeContractor_findAndHandleShortcuts_rdh | /**
* Searches for shortcuts and calls the given handler on each shortcut that is found. The graph is not directly
* changed by this method.
* Returns the 'degree' of the given node (disregarding edges from/to already contracted nodes).
* Note that here the degree is not the total number of adjacent edges, but only... | 3.26 |
graphhopper_NodeBasedNodeContractor_calculatePriority_rdh | /**
* Warning: the calculated priority must NOT depend on priority(v) and therefore findAndHandleShortcuts should also not
* depend on the priority(v). Otherwise updating the priority before contracting in contractNodes() could lead to
* a slowish or even endless loop.
*/
@Override
public float calculatePriority(in... | 3.26 |
graphhopper_StringEncodedValue_roundUp_rdh | /**
*
* @param value
* the value to be rounded
* @return the value rounded to the highest integer with the same number of leading zeros
*/
private static int roundUp(int value) { return (-1) >>> Integer.numberOfLeadingZeros(value);
} | 3.26 |
graphhopper_StringEncodedValue_getValues_rdh | /**
*
* @return an unmodifiable List of the current values
*/
public List<String> getValues() {
return Collections.unmodifiableList(values);
} | 3.26 |
graphhopper_FootPriorityParser_collect_rdh | /**
*
* @param weightToPrioMap
* associate a weight with every priority. This sorted map allows
* subclasses to 'insert' more important priorities as well as overwrite determined priorities.
*/
void collect(ReaderWay way, TreeMap<Double, Integer> weightToPrioMap) {
String highway = way.getTag("highway");... | 3.26 |
graphhopper_SpatialKeyAlgo_getBits_rdh | /**
*
* @return the number of involved bits
*/
public int getBits() {
return allBits;
} | 3.26 |
graphhopper_GtfsStorage_postInit_rdh | // TODO: Refactor initialization
public void postInit() {
LocalDate latestStartDate = LocalDate.ofEpochDay(this.gtfsFeeds.values().stream().mapToLong(f -> f.getStartDate().toEpochDay()).max().getAsLong());
LocalDate earliestEndDate = LocalDate.ofEpochDay(this.gtfsFeeds.values().stream().mapToLong(f -> f.getEndD... | 3.26 |
graphhopper_OSMValueExtractor_stringToKmh_rdh | /**
*
* @return the speed in km/h
*/
public static double stringToKmh(String str) {
if (Helper.isEmpty(str))
return
Double.NaN;
if ("walk".equals(str))
return 6;
// on some German autobahns and a very few other places
if ("none... | 3.26 |
graphhopper_OSMValueExtractor_conditionalWeightToTons_rdh | /**
* This parses the weight for a conditional value like "delivery @ (weight > 7.5)"
*/
public static double conditionalWeightToTons(String value) {
try {
int index = value.indexOf("weight>");// maxweight or weight
if (index < 0) {
index = value.indexOf("weight >");
if (i... | 3.26 |
graphhopper_QueryOverlayBuilder_buildVirtualEdges_rdh | /**
* For all specified snaps calculate the snapped point and if necessary set the closest node
* to a virtual one and reverse the closest edge. Additionally the wayIndex can change if an edge is
* swapped.
*/private void buildVirtualEdges(List<Snap> snaps) {
GHIntObjectHashMap<List<Snap>> edge2res = new GHIn... | 3.26 |
graphhopper_OSMNodeData_addCopyOfNode_rdh | /**
* Creates a copy of the coordinates stored for the given node ID
*
* @return the (artificial) OSM node ID created for the copied node and the associated ID
*/
SegmentNode addCopyOfNode(SegmentNode node) {
GHPoint3D point = getCoordinates(node.id);
if (point == null)
throw new IllegalStateExcepti... | 3.26 |
graphhopper_OSMNodeData_addCoordinatesIfMapped_rdh | /**
* Stores the given coordinates for the given OSM node ID, but only if a non-empty node type was set for this
* OSM node ID previously.
*
* @return the node type this OSM node was associated with before this method was called
*/
public long addCoordinatesIfMapped(long osmNodeId, double lat, double lon, DoubleSu... | 3.26 |
graphhopper_OSMNodeData_getNodeCount_rdh | /**
*
* @return the number of mapped nodes (tower + pillar, but also including pillar nodes that were converted to tower)
*/
public long getNodeCount() {
return idsByOsmNodeIds.getSize();
} | 3.26 |
graphhopper_OSMNodeData_getNodeTagCapacity_rdh | /**
*
* @return the number of nodes for which we store tags
*/
public long getNodeTagCapacity() {
return nodeKVStorage.getCapacity();
} | 3.26 |
graphhopper_AlternativeRoute_isAlreadyExisting_rdh | /**
* This method returns true if the specified tid is already existent in the
* traversalIDMap
*/
boolean isAlreadyExisting(final int tid) {
final AtomicBoolean exists = new AtomicBoolean(false);
traversalIdMap.forEach(new IntObjectPredicate<IntSet>() {
@Override
public boole... | 3.26 |
graphhopper_AlternativeRoute_addToMap_rdh | /**
* This method adds the traversal IDs of the specified path as set to the specified map.
*/
AtomicInteger addToMap(GHIntObjectHashMap<IntSet> map, Path path) {
IntSet set = new GHIntHashSet(); final AtomicInteger startTID = new AtomicInteger(-1);
for (EdgeIteratorState iterState : path.calcEdges()) {
... | 3.26 |
graphhopper_AlternativeRoute_getFirstShareEE_rdh | /**
* Extract path until we stumble over an existing traversal id
*/
SPTEntry getFirstShareEE(SPTEntry startEE, boolean reverse) {
while (startEE.parent != null) {
// TODO we could make use of traversal ID directly if stored in SPTEntry
int tid = traversalMode.createTraversalId(graph.getEdgeIterat... | 3.26 |
graphhopper_AlternativeRoute_isBestPath_rdh | // returns true if fromSPTEntry is identical to the specified best path
boolean isBestPath(SPTEntry fromSPTEntry) {
if (traversalMode.isEdgeBased()) {
if (GHUtility... | 3.26 |
graphhopper_AlternativeRoute_m0_rdh | /**
* Return the current worst weight for all alternatives
*/
double m0() {
if (alternatives.isEmpty())
throw new IllegalStateException("Empty alternative list cannot happen");
return alternatives.get(alternatives.size() - 1).sortBy;
} | 3.26 |
graphhopper_GHLongLongBTree_getCapacity_rdh | /**
*
* @return used bytes
*/long getCapacity() { long cap = (((keys.length * (8 + 4)) + (3 * 12)) + 4) + 1;
if (!isLeaf) {
cap += children.length * 4;for (int i = 0; i < children.length; i++) {
if (children[i] != null) {
cap += children[i].getCapacity();
}
}
}return cap;
} | 3.26 |
graphhopper_GHLongLongBTree_m0_rdh | /**
*
* @return memory usage in MB
*/
@Override
public int m0() {
return Math.round(root.getCapacity() / Helper.MB);
} | 3.26 |
graphhopper_RAMDataAccess_store_rdh | /**
*
* @param store
* true if in-memory data should be saved when calling flush
*/
public RAMDataAccess store(boolean store) {
this.store = store;
return this;
} | 3.26 |
graphhopper_Transfers_getTransfersToStop_rdh | // Starts implementing the proposed GTFS extension for route and trip specific transfer rules.
// So far, only the route is supported.
List<Transfer> getTransfersToStop(String toStopId, String toRouteId) {
final List<Transfer> allInboundTransfers =
transfersToStop.getOrDefault(toStopId, Collections.emptyList()... | 3.26 |
graphhopper_DistanceCalc3D_m0_rdh | /**
*
* @param fromHeight
* in meters above 0
* @param toHeight
* in meters above 0
*/
public double m0(double fromLat, double fromLon, double fromHeight, double
toLat, double toLon, double toHeight) {
double len = super.calcDist(fromLat, fromLon, toLat, toLon);
double delta = Math.abs(toHeight - fr... | 3.26 |
graphhopper_MatrixResponse_hasErrors_rdh | /**
*
* @return true if one or more error found
*/
public boolean hasErrors() {
return !errors.isEmpty();
} | 3.26 |
graphhopper_MatrixResponse_getWeight_rdh | /**
* Returns the weight for the specific entry (from -> to) in arbitrary units ('costs'), or
* {@link Double#MAX_VALUE} in case no connection was found (and {@link GHMRequest#setFailFast(boolean)} was set
* to true).
*/
public double getWeight(int from, int to) {
if (hasErrors()) {
throw new Illegal... | 3.26 |
graphhopper_MatrixResponse_getTime_rdh | /**
* Returns the time for the specific entry (from -> to) in milliseconds or {@link Long#MAX_VALUE} in case
* no connection was found (and {@link GHMRequest#setFailFast(boolean)} was set to true).
*/
public long getTime(int from, int to) {
if (hasErrors()) {
throw new IllegalStateException((((("Can... | 3.26 |
graphhopper_MatrixResponse_getDistance_rdh | /**
* Returns the distance for the specific entry (from -> to) in meter or {@link Double#MAX_VALUE} in case
* no connection was found (and {@link GHMRequest#setFailFast(boolean)} was set to true).
*/public double getDistance(int from, int to) {
if (hasErrors()) {
throw new IllegalStateException(((((... | 3.26 |
graphhopper_MatrixResponse_hasProblems_rdh | /**
*
* @return true if there are invalid or disconnected points (which both do not yield an error in case we do not fail fast).
* @see GHMRequest#setFailFast(boolean)
*/
public boolean hasProblems() {
return
((!disconnectedPoints.isEmpty()) || (!invalidFromPoints.isEmpty())) || (!invalidToPoints.isEmpty());
} | 3.26 |
graphhopper_QueryGraph_m0_rdh | /**
* Assigns the 'unfavored' flag to a virtual edge (for both directions)
*/
public void m0(int virtualEdgeId) {
if (!isVirtualEdge(virtualEdgeId))return;
VirtualEdgeIteratorState edge = getVirtualEdge(getInternalVirtualEdgeId(virtualEdgeId));
edge.setUnfavored(true);
unfavoredEdges.add(edge);
/... | 3.26 |
graphhopper_QueryGraph_clearUnfavoredStatus_rdh | /**
* Removes the 'unfavored' status of all virtual edges.
*/
public void clearUnfavoredStatus() {
for (VirtualEdgeIteratorState edge : unfavoredEdges) {
edge.setUnfavored(false);
}
unfavoredEdges.clear();
} | 3.26 |
graphhopper_StopWatch_getCurrentSeconds_rdh | /**
* returns the total elapsed time on this stopwatch without the need of stopping it
*/
public float getCurrentSeconds() {
if (notStarted()) {
return 0;
}
long lastNanos = (lastTime < 0) ? 0 : System.nanoTime() - lastTime;
return (elapsedNanos
+ lastNanos) / 1.0E9F;
} | 3.26 |
graphhopper_StopWatch_getMillisDouble_rdh | /**
* returns the elapsed time in ms but includes the fraction as well to get a precise value
*/
public double getMillisDouble() {
return elapsedNanos
/ 1000000.0;
} | 3.26 |
graphhopper_PrepareContractionHierarchies_useFixedNodeOrdering_rdh | /**
* Instead of heuristically determining a node ordering for the graph contraction it is also possible
* to use a fixed ordering. For example this allows re-using a previously calculated node ordering.
* This will speed up CH preparation, but might lead to slower queries.
*/
public PrepareContractionHierarchies
u... | 3.26 |
graphhopper_ViaRouting_lookup_rdh | /**
*
* @throws MultiplePointsNotFoundException
* in case one or more points could not be resolved
*/
public static List<Snap> lookup(EncodedValueLookup lookup, List<GHPoint> points, EdgeFilter snapFilter, LocationIndex locationIndex, List<String> snapPreventions, List<String> pointHints, ... | 3.26 |
graphhopper_ViaRouting_buildEdgeRestrictions_rdh | /**
* Determines restrictions for the start/target edges to account for the heading, pass_through and curbside parameters
* for a single via-route leg.
*
* @param fromHeading
* the heading at the start node of this leg, or NaN if no restriction should be applied
* @param toHeading
* the heading at the target... | 3.26 |
graphhopper_CarAccessParser_isBackwardOneway_rdh | /**
* make sure that isOneway is called before
*/
protected boolean isBackwardOneway(ReaderWay way) {
return (way.hasTag("oneway", "-1") || way.hasTag("vehicle:forward", restrictedValues)) || way.hasTag("motor_vehicle:forward", restrictedValues);
} | 3.26 |
graphhopper_CarAccessParser_isForwardOneway_rdh | /**
* make sure that isOneway is called before
*/
protected boolean isForwardOneway(ReaderWay way) {
return ((!way.hasTag("oneway", "-1")) && (!way.hasTag("vehicle:forward", restrictedValues))) && (!way.hasTag("motor_vehicle:forward", restrictedValues));
} | 3.26 |
graphhopper_VirtualEdgeIteratorState_getOriginalEdgeKey_rdh | /**
* This method returns the original (not virtual!) edge key. I.e. also the direction is
* already correctly encoded.
*
* @see EdgeIteratorState#getEdgeKey()
*/
public int
getOriginalEdgeKey() {
return originalEdgeKey;
} | 3.26 |
graphhopper_MinHeapWithUpdate_peekValue_rdh | /**
*
* @return the value of the next element to be polled
*/
public float peekValue() {
return vals[1];
} | 3.26 |
graphhopper_MinHeapWithUpdate_peekId_rdh | /**
*
* @return the id of the next element to be polled, i.e. the same as calling poll() without removing the element
*/
public int peekId() {
return tree[1];
} | 3.26 |
graphhopper_MinHeapWithUpdate_contains_rdh | /**
*
* @return true if the heap contains an element with the given id
*/
public boolean
contains(int id) {
checkIdInRange(id);
return positions[id] != NOT_PRESENT;
} | 3.26 |
graphhopper_MinHeapWithUpdate_update_rdh | /**
* Updates the element with the given id. The complexity of this method is O(log(N)), just like push/poll.
* Its illegal to update elements that are not contained in the heap. Use {@link #contains} to check the existence
* of an id.
*/
public void update(int id, float value) {
checkIdInRange(id);
int ind... | 3.26 |
graphhopper_AccessFilter_allEdges_rdh | /**
* Accepts all edges that are either forward or backward according to the given accessEnc.
* Edges where neither one of the flags is enabled will still not be accepted. If you need to retrieve all edges
* regardless of their encoding use {@link EdgeFilter#ALL_EDGES} instead.
*/
public static AccessFilter allEdge... | 3.26 |
graphhopper_DistanceCalcEuclidean_calcNormalizedDist_rdh | /**
* Returns the specified length in normalized meter.
*/
@Override
public double
calcNormalizedDist(double dist) {
return dist * dist;
} | 3.26 |
graphhopper_AStar_setApproximation_rdh | /**
*
* @param approx
* defines how distance to goal Node is approximated
*/
public AStar setApproximation(WeightApproximator approx) {
weightApprox = approx;
return this;} | 3.26 |
graphhopper_MaxWeight_create_rdh | /**
* Currently enables to store 0.1 to max=0.1*2⁸ tons and infinity. If a value is between the maximum and infinity
* it is assumed to use the maximum value. To save bits it might make more sense to store only a few values like
* it was done with the MappedDecimalEncodedValue still handling (or rounding) of unknown... | 3.26 |
graphhopper_Helper_degreeToInt_rdh | /**
* Converts into an integer to be compatible with the still limited DataAccess class (accepts
* only integer values). But this conversion also reduces memory consumption where the precision
* loss is acceptable. As +- 180° and +-90° are assumed as maximum values.
*
* @return the integer of the specified degree
... | 3.26 |
graphhopper_Helper_eleToInt_rdh | /**
* Converts elevation value (in meters) into integer for storage.
*/
public static int eleToInt(double ele) {
if (ele >= Integer.MAX_VALUE)
return Integer.MAX_VALUE;
return ((int) (ele * ELE_FACTOR));
} | 3.26 |
graphhopper_Helper_createFormatter_rdh | /**
* Creates a SimpleDateFormat with ENGLISH locale.
*/
public static DateFormat createFormatter(String str) {
DateFormat df = new SimpleDateFormat(str, Locale.ENGLISH);
df.setTimeZone(UTC);
return df;
} | 3.26 |
graphhopper_Helper_keepIn_rdh | /**
* This methods returns the value or min if too small or max if too big.
*/
public static double keepIn(double value, double min, double max) {
return Math.max(min, Math.min(value, max));
} | 3.26 |
graphhopper_Helper_isFileMapped_rdh | /**
* Determines if the specified ByteBuffer is one which maps to a file!
*/
public static boolean isFileMapped(ByteBuffer bb) {
if (bb instanceof
MappedByteBuffer) {
try {
((MappedByteBuffer) (bb)).isLoaded();
return true;
} catch (UnsupportedOperationException ex) {
}
}
return false;
} | 3.26 |
graphhopper_Helper_intToEle_rdh | /**
* Converts the integer value retrieved from storage into elevation (in meters). Do not expect
* more precision than meters although it currently is!
*/
public static double intToEle(int integEle) {
if (integEle == Integer.MAX_VALUE)
return Double.MAX_VALUE;
return integEle / ELE_FACTOR;} | 3.26 |
graphhopper_Helper_staticHashCode_rdh | /**
* Produces a static hashcode for a string that is platform independent and still compatible to the default
* of openjdk. Do not use for performance critical applications.
*
* @see String#hashCode()
*/
public static int staticHashCode(String str) {
int len = str.length();
int val = 0;
for (int idx = 0; idx < le... | 3.26 |
graphhopper_Helper_toObject_rdh | /**
* This method probes the specified string for a boolean, int, long, float and double. If all this fails it returns
* the unchanged string.
*/
public static Object toObject(String string) {
if ("true".equalsIgnoreCase(string) || "false".equalsIgnoreCase(string))
return Boolean.parseBoolean(string);
try {
return... | 3.26 |
graphhopper_Helper_parseList_rdh | /**
* parses a string like [a,b,c]
*/
public static List<String> parseList(String listStr) {
String trimmed = listStr.trim();
if (trimmed.length() < 2)
return
Collections.emptyList();
String[] items = trimmed.substring(1, trimmed.length() - 1).split(",");
List<String> result = new ArrayList<>();
for (String item : ... | 3.26 |
graphhopper_Helper_intToDegree_rdh | /**
* Converts back the integer value.
*
* @return the degree value of the specified integer
*/
public static double intToDegree(int storedInt) {
if (storedInt == Integer.MAX_VALUE)
return
Double.MAX_VALUE;
if (storedInt == (-Integer.MAX_VALUE))
return -Double.MAX_VALUE;
return ((double) (storedInt)) / DEGREE_FACT... | 3.26 |
graphhopper_Helper_round_rdh | /**
* Round the value to the specified number of decimal places, i.e. decimalPlaces=2 means we round to two decimal
* places. Using negative values like decimalPlaces=-2 means we round to two places before the decimal point.
*/
public static double round(double value, int decimalPlaces) {
double factor = Math.pow(10... | 3.26 |
graphhopper_Snap_calcSnappedPoint_rdh | /**
* Calculates the closest point on the edge from the query point. If too close to a tower or pillar node this method
* might change the snappedPosition and wayIndex.
*/
public void calcSnappedPoint(DistanceCalc
... | 3.26 |
graphhopper_Snap_getSnappedPosition_rdh | /**
*
* @return 0 if on edge. 1 if on pillar node and 2 if on tower node.
*/
public Position getSnappedPosition() {
return snappedPosition;
} | 3.26 |
graphhopper_Snap_isValid_rdh | /**
*
* @return true if a closest node was found
*/
public boolean isValid() {
return closestNode >= 0;
} | 3.26 |
graphhopper_Snap_getQueryDistance_rdh | /**
*
* @return the distance of the query to the snapped coordinates. In meter
*/
public double getQueryDistance() {return queryDistance;
} | 3.26 |
graphhopper_Snap_getSnappedPoint_rdh | /**
* Calculates the position of the query point 'snapped' to a close road segment or node. Call
* calcSnappedPoint before, if not, an IllegalStateException is thrown.
*/
public GHPoint3D getSnappedPoint() {
if (snappedPoint == null)
throw new IllegalStateException("Calculate snapped point before!");
... | 3.26 |
graphhopper_VLongStorage_writeVLong_rdh | /**
* Writes an long in a variable-length format. Writes between one and nine bytes. Smaller values
* take fewer bytes. Negative numbers are not supported.
* <p>
* The format is described further in Lucene its DataOutput#writeVInt(int)
* <p>
* See DataInput readVLong of Lucene
*/
... | 3.26 |
graphhopper_VLongStorage_readVLong_rdh | /**
* Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller
* values take fewer bytes. Negative numbers are not supported.
* <p>
* The format is described further in DataOutput writeVInt(int) from Lucene.
*/
public long readVLong()
{
/* This is the original code of this method,
b... | 3.26 |
graphhopper_PathDetailsFromEdges_calcDetails_rdh | /**
* Calculates the PathDetails for a Path. This method will return fast, if there are no calculators.
*
* @param pathBuilderFactory
* Generates the relevant PathBuilders
* @return List of PathDetails for this Path
*/
public static Map<String, List<PathDetail>> calcDetails(Path path, EncodedValueLookup evLooku... | 3.26 |
graphhopper_ArrayUtil_permutation_rdh | /**
* Creates an IntArrayList filled with a permutation of the numbers 0,1,2,...,size-1
*/
public static IntArrayList permutation(int size, Random rnd) {
IntArrayList result = iota(size);
shuffle(result, rnd);
return result;
} | 3.26 |
graphhopper_ArrayUtil_withoutConsecutiveDuplicates_rdh | /**
* Creates a copy of the given list where all consecutive duplicates are removed
*/
public static IntIndexedContainer withoutConsecutiveDuplicates(IntIndexedContainer arr) {
IntArrayList
result = new IntArrayList();
if
(arr.isEmpty())
return result;
int prev = arr.get(0);
result.ad... | 3.26 |
graphhopper_ArrayUtil_iota_rdh | /**
* Creates an IntArrayList filled with the integers 0,1,2,3,...,size-1
*/
public static IntArrayList iota(int size) {
return
range(0, size);
} | 3.26 |
graphhopper_ArrayUtil_transform_rdh | /**
* Maps one array using another, i.e. every element arr[x] is replaced by map[arr[x]]
*/
public static void transform(IntIndexedContainer arr, IntIndexedContainer map) {
for (int i = 0; i < arr.size(); ++i)
arr.set(i, map.get(arr.get(i)));
} | 3.26 |
graphhopper_ArrayUtil_invert_rdh | /**
* Creates a new array where each element represents the index position of this element in the given array
* or is set to -1 if this element does not appear in the input array. None of the elements of the input array may
* be equal or larger than the arrays length.
*/
public static int[] invert(int[] arr) {
... | 3.26 |
graphhopper_ArrayUtil_applyOrder_rdh | /**
* Creates a copy of the given array such that it is ordered by the given order.
* The order can be shorter or equal, but not longer than the array.
*/
public static int[] applyOrder(int[] arr, int[]
order) {
if (order.length > arr.length)
throw new IllegalArgumentException("sort order must not be sho... | 3.26 |
graphhopper_ArrayUtil_shuffle_rdh | /**
* Shuffles the elements of the given list in place and returns it
*/
public static IntArrayList shuffle(IntArrayList list, Random random) {int maxHalf = list.size() / 2;
for (int x1 = 0; x1 < maxHalf; x1++) {
int x2 = random.nextInt(maxHalf) + maxHalf;
int tmp = list.buffer[x1];
list.b... | 3.26 |
graphhopper_ArrayUtil_zero_rdh | /**
* Creates an IntArrayList filled with zeros
*/
public static IntArrayList zero(int size) {
IntArrayList result =
new IntArrayList(size);
result.elementsCount = size;
return result;
} | 3.26 |
graphhopper_ArrayUtil_range_rdh | /**
* Creates an IntArrayList filled with the integers [startIncl,endExcl[
*/
public static IntArrayList range(int startIncl, int endExcl) {
IntArrayList result = new IntArrayList(endExcl - startIncl);
result.elementsCount = endExcl - startIncl;
for (int i
= 0; i < result.size(); ++i)
result... | 3.26 |
graphhopper_ArrayUtil_reverse_rdh | /**
* Reverses the order of the given list's elements in place and returns it
*/
public static IntArrayList reverse(IntArrayList list) {
final int[] buffer = list.buffer;
int tmp;
for (int start = 0, end
= list.size() - 1; start < end; start++ , end--) {
// swap the values
tmp = buffer... | 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.