use of com.yandex.mapkit.geometry.Polyline in project react-native-yamap by volga-volga.
the class YamapPolyline method setPolygonPoints.
// props
public void setPolygonPoints(ArrayList<Point> points) {
_points = points != null ? points : new ArrayList<Point>();
polyline = new Polyline(_points);
updatePolyline();
}
use of com.yandex.mapkit.geometry.Polyline in project react-native-yamap by volga-volga.
the class YamapView method convertRouteSection.
private WritableMap convertRouteSection(Route route, final Section section, Polyline geometry, Weight routeWeight, int routeIndex) {
SectionMetadata.SectionData data = section.getMetadata().getData();
WritableMap routeMetadata = Arguments.createMap();
WritableMap routeWeightData = Arguments.createMap();
WritableMap sectionWeightData = Arguments.createMap();
Map<String, ArrayList<String>> transports = new HashMap<>();
routeWeightData.putString("time", routeWeight.getTime().getText());
routeWeightData.putInt("transferCount", routeWeight.getTransfersCount());
routeWeightData.putDouble("walkingDistance", routeWeight.getWalkingDistance().getValue());
sectionWeightData.putString("time", section.getMetadata().getWeight().getTime().getText());
sectionWeightData.putInt("transferCount", section.getMetadata().getWeight().getTransfersCount());
sectionWeightData.putDouble("walkingDistance", section.getMetadata().getWeight().getWalkingDistance().getValue());
routeMetadata.putMap("sectionInfo", sectionWeightData);
routeMetadata.putMap("routeInfo", routeWeightData);
routeMetadata.putInt("routeIndex", routeIndex);
final WritableArray stops = new WritableNativeArray();
for (RouteStop stop : section.getStops()) {
stops.pushString(stop.getStop().getName());
}
routeMetadata.putArray("stops", stops);
if (data.getTransports() != null) {
for (Transport transport : data.getTransports()) {
for (String type : transport.getLine().getVehicleTypes()) {
if (type.equals("suburban"))
continue;
if (transports.get(type) != null) {
ArrayList<String> list = transports.get(type);
if (list != null) {
list.add(transport.getLine().getName());
transports.put(type, list);
}
} else {
ArrayList<String> list = new ArrayList<>();
list.add(transport.getLine().getName());
transports.put(type, list);
}
routeMetadata.putString("type", type);
int color = Color.BLACK;
if (transportHasStyle(transport)) {
try {
color = transport.getLine().getStyle().getColor();
} catch (Exception ignored) {
}
}
routeMetadata.putString("sectionColor", formatColor(color));
}
}
} else {
routeMetadata.putString("sectionColor", formatColor(Color.DKGRAY));
if (section.getMetadata().getWeight().getWalkingDistance().getValue() == 0) {
routeMetadata.putString("type", "waiting");
} else {
routeMetadata.putString("type", "walk");
}
}
WritableMap wTransports = Arguments.createMap();
for (Map.Entry<String, ArrayList<String>> entry : transports.entrySet()) {
wTransports.putArray(entry.getKey(), Arguments.fromList(entry.getValue()));
}
routeMetadata.putMap("transports", wTransports);
Polyline subpolyline = SubpolylineHelper.subpolyline(route.getGeometry(), section.getGeometry());
List<Point> linePoints = subpolyline.getPoints();
WritableArray jsonPoints = Arguments.createArray();
for (Point point : linePoints) {
WritableMap jsonPoint = Arguments.createMap();
jsonPoint.putDouble("lat", point.getLatitude());
jsonPoint.putDouble("lon", point.getLongitude());
jsonPoints.pushMap(jsonPoint);
}
routeMetadata.putArray("points", jsonPoints);
return routeMetadata;
}
use of com.yandex.mapkit.geometry.Polyline in project react-native-yamap by volga-volga.
the class YamapView method convertDrivingRouteSection.
private WritableMap convertDrivingRouteSection(DrivingRoute route, final DrivingSection section, int routeIndex) {
com.yandex.mapkit.directions.driving.Weight routeWeight = route.getMetadata().getWeight();
WritableMap routeMetadata = Arguments.createMap();
WritableMap routeWeightData = Arguments.createMap();
WritableMap sectionWeightData = Arguments.createMap();
Map<String, ArrayList<String>> transports = new HashMap<>();
routeWeightData.putString("time", routeWeight.getTime().getText());
routeWeightData.putString("timeWithTraffic", routeWeight.getTimeWithTraffic().getText());
routeWeightData.putDouble("distance", routeWeight.getDistance().getValue());
sectionWeightData.putString("time", section.getMetadata().getWeight().getTime().getText());
sectionWeightData.putString("timeWithTraffic", section.getMetadata().getWeight().getTimeWithTraffic().getText());
sectionWeightData.putDouble("distance", section.getMetadata().getWeight().getDistance().getValue());
routeMetadata.putMap("sectionInfo", sectionWeightData);
routeMetadata.putMap("routeInfo", routeWeightData);
routeMetadata.putInt("routeIndex", routeIndex);
final WritableArray stops = new WritableNativeArray();
routeMetadata.putArray("stops", stops);
routeMetadata.putString("sectionColor", formatColor(Color.DKGRAY));
if (section.getMetadata().getWeight().getDistance().getValue() == 0) {
routeMetadata.putString("type", "waiting");
} else {
routeMetadata.putString("type", "car");
}
WritableMap wTransports = Arguments.createMap();
routeMetadata.putMap("transports", wTransports);
Polyline subpolyline = SubpolylineHelper.subpolyline(route.getGeometry(), section.getGeometry());
List<Point> linePoints = subpolyline.getPoints();
WritableArray jsonPoints = Arguments.createArray();
for (Point point : linePoints) {
WritableMap jsonPoint = Arguments.createMap();
jsonPoint.putDouble("lat", point.getLatitude());
jsonPoint.putDouble("lon", point.getLongitude());
jsonPoints.pushMap(jsonPoint);
}
routeMetadata.putArray("points", jsonPoints);
return routeMetadata;
}
Aggregations