Update srtm data
This commit is contained in:
parent
6ff597b010
commit
9c025e2913
5 changed files with 102 additions and 6 deletions
|
@ -74,14 +74,15 @@ public class BinaryInspector {
|
||||||
in.inspector(new String[] {
|
in.inspector(new String[] {
|
||||||
// "-vpoi",
|
// "-vpoi",
|
||||||
// "-vmap", "-vmapobjects", // "-vmapcoordinates",
|
// "-vmap", "-vmapobjects", // "-vmapcoordinates",
|
||||||
// "-vrouting",
|
"-vrouting",
|
||||||
"-vtransport",
|
// "-vtransport",
|
||||||
// "-vaddress", "-vcities","-vstreetgroups",
|
// "-vaddress", "-vcities","-vstreetgroups",
|
||||||
// "-vstreets", "-vbuildings", "-vintersections",
|
// "-vstreets", "-vbuildings", "-vintersections",
|
||||||
// "-lang=ru",
|
// "-lang=ru",
|
||||||
// "-bbox=4.8486,52.3084,4.8747,52.2970",
|
// "-bbox=30.4981,50.4424,30.5195,50.4351",
|
||||||
// "-osm="+System.getProperty("maps.dir")+"/map.obf.osm",
|
// "-osm="+System.getProperty("maps.dir")+"/map.obf.osm",
|
||||||
System.getProperty("maps.dir")+"/Map.obf"
|
System.getProperty("maps.dir")+"/Map.obf"
|
||||||
|
// System.getProperty("maps.dir")+"/Ukraine_kiev-city_europe.obf"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
in.inspector(args);
|
in.inspector(args);
|
||||||
|
|
|
@ -62,7 +62,8 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
OBSTACLES("obstacle_time"),
|
OBSTACLES("obstacle_time"),
|
||||||
ROUTING_OBSTACLES("obstacle"),
|
ROUTING_OBSTACLES("obstacle"),
|
||||||
ONEWAY("oneway"),
|
ONEWAY("oneway"),
|
||||||
PENALTY_TRANSITION("penalty_transition");
|
PENALTY_TRANSITION("penalty_transition"),
|
||||||
|
OBSTACLE_SRTM_ALT_SPEED("obstacle_srtm_alt_speed");
|
||||||
public final String nm;
|
public final String nm;
|
||||||
RouteDataObjectAttribute(String name) {
|
RouteDataObjectAttribute(String name) {
|
||||||
nm = name;
|
nm = name;
|
||||||
|
|
|
@ -360,6 +360,7 @@ public class RouteResultPreparation {
|
||||||
}
|
}
|
||||||
additional.append("start_bearing = \"").append(res.getBearingBegin()).append("\" ");
|
additional.append("start_bearing = \"").append(res.getBearingBegin()).append("\" ");
|
||||||
additional.append("end_bearing = \"").append(res.getBearingEnd()).append("\" ");
|
additional.append("end_bearing = \"").append(res.getBearingEnd()).append("\" ");
|
||||||
|
additional.append("height = \"").append(Arrays.toString(res.getHeightValues())).append("\" ");
|
||||||
additional.append("description = \"").append(res.getDescription()).append("\" ");
|
additional.append("description = \"").append(res.getDescription()).append("\" ");
|
||||||
println(MessageFormat.format("\t<segment id=\"{0}\" oid=\"{1}\" start=\"{2}\" end=\"{3}\" {4}/>",
|
println(MessageFormat.format("\t<segment id=\"{0}\" oid=\"{1}\" start=\"{2}\" end=\"{3}\" {4}/>",
|
||||||
(res.getObject().getId() >> (BinaryInspector.SHIFT_ID )) + "", res.getObject().getId() + "",
|
(res.getObject().getId() >> (BinaryInspector.SHIFT_ID )) + "", res.getObject().getId() + "",
|
||||||
|
@ -378,7 +379,7 @@ public class RouteResultPreparation {
|
||||||
int[] pointNameTypes = res.getObject().getPointNameTypes(k);
|
int[] pointNameTypes = res.getObject().getPointNameTypes(k);
|
||||||
if (tp != null || pointNameTypes != null) {
|
if (tp != null || pointNameTypes != null) {
|
||||||
StringBuilder bld = new StringBuilder();
|
StringBuilder bld = new StringBuilder();
|
||||||
bld.append("<point ");
|
bld.append("<point " + (k));
|
||||||
if (tp != null) {
|
if (tp != null) {
|
||||||
for (int t = 0; t < tp.length; t++) {
|
for (int t = 0; t < tp.length; t++) {
|
||||||
RouteTypeRule rr = res.getObject().region.quickGetEncodingRule(tp[t]);
|
RouteTypeRule rr = res.getObject().region.quickGetEncodingRule(tp[t]);
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package net.osmand.router;
|
package net.osmand.router;
|
||||||
|
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +27,7 @@ public class RouteSegmentResult {
|
||||||
private String description = "";
|
private String description = "";
|
||||||
// this make not possible to make turns in between segment result for now
|
// this make not possible to make turns in between segment result for now
|
||||||
private TurnType turnType;
|
private TurnType turnType;
|
||||||
|
public static int HEIGHT_UNDEFINED = -80000;
|
||||||
|
|
||||||
|
|
||||||
public RouteSegmentResult(RouteDataObject object, int startPointIndex, int endPointIndex) {
|
public RouteSegmentResult(RouteDataObject object, int startPointIndex, int endPointIndex) {
|
||||||
|
@ -32,6 +37,83 @@ public class RouteSegmentResult {
|
||||||
updateCapacity();
|
updateCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float[] getHeightValues() {
|
||||||
|
int startHeight = Algorithms.parseIntSilently(object.getValue("osmand_ele_start"), HEIGHT_UNDEFINED);
|
||||||
|
int endHeight = Algorithms.parseIntSilently(object.getValue("osmand_ele_end"), startHeight);
|
||||||
|
if(startHeight == HEIGHT_UNDEFINED) {
|
||||||
|
return new float[0];
|
||||||
|
}
|
||||||
|
TIntArrayList list = new TIntArrayList();
|
||||||
|
float[] pf = new float[2*object.getPointsLength()];
|
||||||
|
double dist = 0;
|
||||||
|
double plon = 0;
|
||||||
|
double plat = 0;
|
||||||
|
int prevHeight = startHeight;
|
||||||
|
for(int k = 0; k < object.getPointsLength(); k++) {
|
||||||
|
double lon = MapUtils.get31LongitudeX(object.getPoint31XTile(k));
|
||||||
|
double lat = MapUtils.get31LatitudeY(object.getPoint31YTile(k));
|
||||||
|
if(k > 0) {
|
||||||
|
double dd = MapUtils.getDistance(plat, plon, lat, lon);
|
||||||
|
int height = HEIGHT_UNDEFINED;
|
||||||
|
if(k == object.getPointsLength() - 1) {
|
||||||
|
height = endHeight;
|
||||||
|
} else {
|
||||||
|
int[] tps = object.getPointTypes(k);
|
||||||
|
if (tps != null) {
|
||||||
|
for (int id : tps) {
|
||||||
|
RouteTypeRule rt = object.region.quickGetEncodingRule(id);
|
||||||
|
if (rt.getTag().equals("osmand_ele_asc")) {
|
||||||
|
height = (int) (prevHeight + Float.parseFloat(rt.getValue()));
|
||||||
|
break;
|
||||||
|
} else if (rt.getTag().equals("osmand_ele_desc")) {
|
||||||
|
height = (int) (prevHeight - Float.parseFloat(rt.getValue()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pf[2*k] = (float) dd;
|
||||||
|
pf[2*k+1] = height;
|
||||||
|
if(height != HEIGHT_UNDEFINED) {
|
||||||
|
// interpolate undefined
|
||||||
|
double totalDistance = dd;
|
||||||
|
int startUndefined = k;
|
||||||
|
while(startUndefined - 1 >= 0 && pf[2*(startUndefined - 1)+1] == HEIGHT_UNDEFINED) {
|
||||||
|
startUndefined --;
|
||||||
|
totalDistance += pf[2*(startUndefined)];
|
||||||
|
}
|
||||||
|
if(totalDistance > 0) {
|
||||||
|
double angle = (height - prevHeight) / totalDistance;
|
||||||
|
for(int j = startUndefined; j < k; j++) {
|
||||||
|
pf[2*j+1] = (float) ((pf[2*j] * angle) + pf[2*j-1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prevHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
pf[0] = 0;
|
||||||
|
pf[1] = startHeight;
|
||||||
|
}
|
||||||
|
plat = lat;
|
||||||
|
plon = lon;
|
||||||
|
}
|
||||||
|
boolean reverse = startPointIndex > endPointIndex;
|
||||||
|
int st = Math.min(startPointIndex, endPointIndex);
|
||||||
|
int end = Math.max(startPointIndex, endPointIndex);
|
||||||
|
|
||||||
|
float[] res = new float[(end - st + 1) * 2];
|
||||||
|
for (int k = 0; k < res.length / 2; k++) {
|
||||||
|
if (k == 0) {
|
||||||
|
res[2 * k] = 0;
|
||||||
|
} else {
|
||||||
|
res[2 * k] = pf[reverse ? (2 * (end - k)) : (2 * (k + st))];
|
||||||
|
}
|
||||||
|
res[2 * k + 1] = pf[reverse ? (2 * (end - k) + 1) : (2 * (k + st) + 1)];
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void updateCapacity() {
|
private void updateCapacity() {
|
||||||
|
|
|
@ -70,6 +70,17 @@ public class Algorithms {
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int parseIntSilently(String input, int def) {
|
||||||
|
if (input != null && input.length() > 0) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(input);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getFileNameWithoutExtension(File f) {
|
public static String getFileNameWithoutExtension(File f) {
|
||||||
|
|
Loading…
Reference in a new issue