Initial version -- added millennium read funcionality
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlBoolean {
|
||||
public static boolean parseBoolean(String str) {
|
||||
return "1".equals(str) || "true".equals(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.GroundOverlay;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlContainer {
|
||||
private String mContainerId;
|
||||
private final ArrayList<KmlContainer> mContainers;
|
||||
private final HashMap<KmlGroundOverlay, GroundOverlay> mGroundOverlays;
|
||||
private final HashMap<KmlPlacemark, Object> mPlacemarks;
|
||||
private final HashMap<String, String> mProperties;
|
||||
private final HashMap<String, String> mStyleMap;
|
||||
private HashMap<String, KmlStyle> mStyles;
|
||||
|
||||
KmlContainer(HashMap<String, String> map, HashMap<String, KmlStyle> map2, HashMap<KmlPlacemark, Object> map3, HashMap<String, String> map4, ArrayList<KmlContainer> arrayList, HashMap<KmlGroundOverlay, GroundOverlay> map5, String str) {
|
||||
this.mProperties = map;
|
||||
this.mPlacemarks = map3;
|
||||
this.mStyles = map2;
|
||||
this.mStyleMap = map4;
|
||||
this.mContainers = arrayList;
|
||||
this.mGroundOverlays = map5;
|
||||
this.mContainerId = str;
|
||||
}
|
||||
|
||||
HashMap<String, KmlStyle> getStyles() {
|
||||
return this.mStyles;
|
||||
}
|
||||
|
||||
void setPlacemark(KmlPlacemark kmlPlacemark, Object obj) {
|
||||
this.mPlacemarks.put(kmlPlacemark, obj);
|
||||
}
|
||||
|
||||
HashMap<String, String> getStyleMap() {
|
||||
return this.mStyleMap;
|
||||
}
|
||||
|
||||
HashMap<KmlGroundOverlay, GroundOverlay> getGroundOverlayHashMap() {
|
||||
return this.mGroundOverlays;
|
||||
}
|
||||
|
||||
public String getContainerId() {
|
||||
return this.mContainerId;
|
||||
}
|
||||
|
||||
public KmlStyle getStyle(String str) {
|
||||
return this.mStyles.get(str);
|
||||
}
|
||||
|
||||
public String getStyleIdFromMap(String str) {
|
||||
return this.mStyleMap.get(str);
|
||||
}
|
||||
|
||||
HashMap<KmlPlacemark, Object> getPlacemarksHashMap() {
|
||||
return this.mPlacemarks;
|
||||
}
|
||||
|
||||
public String getProperty(String str) {
|
||||
return this.mProperties.get(str);
|
||||
}
|
||||
|
||||
public boolean hasProperties() {
|
||||
return this.mProperties.size() > 0;
|
||||
}
|
||||
|
||||
public boolean hasProperty(String str) {
|
||||
return this.mProperties.containsKey(str);
|
||||
}
|
||||
|
||||
public boolean hasContainers() {
|
||||
return this.mContainers.size() > 0;
|
||||
}
|
||||
|
||||
public Iterable<KmlContainer> getContainers() {
|
||||
return this.mContainers;
|
||||
}
|
||||
|
||||
public Iterable<String> getProperties() {
|
||||
return this.mProperties.keySet();
|
||||
}
|
||||
|
||||
public Iterable<KmlPlacemark> getPlacemarks() {
|
||||
return this.mPlacemarks.keySet();
|
||||
}
|
||||
|
||||
public boolean hasPlacemarks() {
|
||||
return this.mPlacemarks.size() > 0;
|
||||
}
|
||||
|
||||
public Iterable<KmlGroundOverlay> getGroundOverlays() {
|
||||
return this.mGroundOverlays.keySet();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("Container{\n properties=");
|
||||
sb.append(this.mProperties);
|
||||
sb.append(",\n placemarks=").append(this.mPlacemarks);
|
||||
sb.append(",\n containers=").append(this.mContainers);
|
||||
sb.append(",\n ground overlays=").append(this.mGroundOverlays);
|
||||
sb.append(",\n style maps=").append(this.mStyleMap);
|
||||
sb.append(",\n styles=").append(this.mStyles);
|
||||
sb.append("\n}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
class KmlContainerParser {
|
||||
private static final String CONTAINER_REGEX = "Folder|Document";
|
||||
private static final String EXTENDED_DATA = "ExtendedData";
|
||||
private static final String GROUND_OVERLAY = "GroundOverlay";
|
||||
private static final String PLACEMARK = "Placemark";
|
||||
private static final String PROPERTY_REGEX = "name|description|visibility|open|address|phoneNumber";
|
||||
private static final String STYLE = "Style";
|
||||
private static final String STYLE_MAP = "StyleMap";
|
||||
private static final String UNSUPPORTED_REGEX = "altitude|altitudeModeGroup|altitudeMode|begin|bottomFov|cookie|displayName|displayMode|end|expires|extrude|flyToView|gridOrigin|httpQuery|leftFov|linkDescription|linkName|linkSnippet|listItemType|maxSnippetLines|maxSessionLength|message|minAltitude|minFadeExtent|minLodPixels|minRefreshPeriod|maxAltitude|maxFadeExtent|maxLodPixels|maxHeight|maxWidth|near|overlayXY|range|refreshMode|refreshInterval|refreshVisibility|rightFov|roll|rotationXY|screenXY|shape|sourceHref|state|targetHref|tessellate|tileSize|topFov|viewBoundScale|viewFormat|viewRefreshMode|viewRefreshTime|when";
|
||||
|
||||
KmlContainerParser() {
|
||||
}
|
||||
|
||||
static KmlContainer createContainer(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
return assignPropertiesToContainer(xmlPullParser);
|
||||
}
|
||||
|
||||
private static KmlContainer assignPropertiesToContainer(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
String name = xmlPullParser.getName();
|
||||
HashMap map = new HashMap();
|
||||
HashMap map2 = new HashMap();
|
||||
HashMap map3 = new HashMap();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
HashMap map4 = new HashMap();
|
||||
HashMap map5 = new HashMap();
|
||||
String attributeValue = xmlPullParser.getAttributeValue(null, "id") != null ? xmlPullParser.getAttributeValue(null, "id") : null;
|
||||
xmlPullParser.next();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals(name)) {
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().matches(UNSUPPORTED_REGEX)) {
|
||||
KmlParser.skip(xmlPullParser);
|
||||
} else if (xmlPullParser.getName().matches(CONTAINER_REGEX)) {
|
||||
arrayList.add(assignPropertiesToContainer(xmlPullParser));
|
||||
} else if (xmlPullParser.getName().matches(PROPERTY_REGEX)) {
|
||||
map.put(xmlPullParser.getName(), xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals(STYLE_MAP)) {
|
||||
setContainerStyleMap(xmlPullParser, map4);
|
||||
} else if (xmlPullParser.getName().equals(STYLE)) {
|
||||
setContainerStyle(xmlPullParser, map2);
|
||||
} else if (xmlPullParser.getName().equals(PLACEMARK)) {
|
||||
setContainerPlacemark(xmlPullParser, map3);
|
||||
} else if (xmlPullParser.getName().equals(EXTENDED_DATA)) {
|
||||
setExtendedDataProperties(xmlPullParser, map);
|
||||
} else if (xmlPullParser.getName().equals(GROUND_OVERLAY)) {
|
||||
map5.put(KmlFeatureParser.createGroundOverlay(xmlPullParser), null);
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlContainer(map, map2, map3, map4, arrayList, map5, attributeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setContainerStyleMap(XmlPullParser xmlPullParser, HashMap<String, String> map) throws XmlPullParserException, IOException {
|
||||
map.putAll(KmlStyleParser.createStyleMap(xmlPullParser));
|
||||
}
|
||||
|
||||
private static void setExtendedDataProperties(XmlPullParser xmlPullParser, HashMap<String, String> map) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
String attributeValue = null;
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals(EXTENDED_DATA)) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals("Data")) {
|
||||
attributeValue = xmlPullParser.getAttributeValue(null, "name");
|
||||
} else if (xmlPullParser.getName().equals("value") && attributeValue != null) {
|
||||
map.put(attributeValue, xmlPullParser.nextText());
|
||||
attributeValue = null;
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setContainerStyle(XmlPullParser xmlPullParser, HashMap<String, KmlStyle> map) throws XmlPullParserException, IOException {
|
||||
if (xmlPullParser.getAttributeValue(null, "id") != null) {
|
||||
KmlStyle kmlStyleCreateStyle = KmlStyleParser.createStyle(xmlPullParser);
|
||||
map.put(kmlStyleCreateStyle.getStyleId(), kmlStyleCreateStyle);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setContainerPlacemark(XmlPullParser xmlPullParser, HashMap<KmlPlacemark, Object> map) throws XmlPullParserException, IOException {
|
||||
map.put(KmlFeatureParser.createPlacemark(xmlPullParser), null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.LatLngBounds;
|
||||
import com.google.maps.android.data.Geometry;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
class KmlFeatureParser {
|
||||
private static final int ALTITUDE_INDEX = 2;
|
||||
private static final String BOUNDARY_REGEX = "outerBoundaryIs|innerBoundaryIs";
|
||||
private static final String COMPASS_REGEX = "north|south|east|west";
|
||||
private static final String EXTENDED_DATA = "ExtendedData";
|
||||
private static final String GEOMETRY_REGEX = "Point|LineString|Polygon|MultiGeometry|Track|MultiTrack";
|
||||
private static final int LATITUDE_INDEX = 1;
|
||||
private static final String LAT_LNG_ALT_SEPARATOR = ",";
|
||||
private static final int LONGITUDE_INDEX = 0;
|
||||
private static final String PROPERTY_REGEX = "name|description|drawOrder|visibility|open|address|phoneNumber";
|
||||
private static final String STYLE_TAG = "Style";
|
||||
private static final String STYLE_URL_TAG = "styleUrl";
|
||||
|
||||
KmlFeatureParser() {
|
||||
}
|
||||
|
||||
private static class LatLngAlt {
|
||||
public final Double altitude;
|
||||
public final LatLng latLng;
|
||||
|
||||
LatLngAlt(LatLng latLng, Double d) {
|
||||
this.latLng = latLng;
|
||||
this.altitude = d;
|
||||
}
|
||||
}
|
||||
|
||||
static KmlPlacemark createPlacemark(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
HashMap map = new HashMap();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
Geometry geometryCreateGeometry = null;
|
||||
String strNextText = null;
|
||||
KmlStyle kmlStyleCreateStyle = null;
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals("Placemark")) {
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals(STYLE_URL_TAG)) {
|
||||
strNextText = xmlPullParser.nextText();
|
||||
} else if (xmlPullParser.getName().matches(GEOMETRY_REGEX)) {
|
||||
geometryCreateGeometry = createGeometry(xmlPullParser, xmlPullParser.getName());
|
||||
} else if (xmlPullParser.getName().matches(PROPERTY_REGEX)) {
|
||||
map.put(xmlPullParser.getName(), xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals(EXTENDED_DATA)) {
|
||||
map.putAll(setExtendedDataProperties(xmlPullParser));
|
||||
} else if (xmlPullParser.getName().equals(STYLE_TAG)) {
|
||||
kmlStyleCreateStyle = KmlStyleParser.createStyle(xmlPullParser);
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlPlacemark(geometryCreateGeometry, strNextText, kmlStyleCreateStyle, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static KmlGroundOverlay createGroundOverlay(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
HashMap map = new HashMap();
|
||||
HashMap map2 = new HashMap();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
String imageUrl = null;
|
||||
float rotation = 0.0f;
|
||||
int i = 1;
|
||||
float f = 0.0f;
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals("GroundOverlay")) {
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals("Icon")) {
|
||||
imageUrl = getImageUrl(xmlPullParser);
|
||||
} else if (xmlPullParser.getName().equals("drawOrder")) {
|
||||
f = Float.parseFloat(xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals("visibility")) {
|
||||
i = Integer.parseInt(xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals(EXTENDED_DATA)) {
|
||||
map.putAll(setExtendedDataProperties(xmlPullParser));
|
||||
} else if (xmlPullParser.getName().equals("rotation")) {
|
||||
rotation = getRotation(xmlPullParser);
|
||||
} else if (xmlPullParser.getName().matches(PROPERTY_REGEX) || xmlPullParser.getName().equals("color")) {
|
||||
map.put(xmlPullParser.getName(), xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().matches(COMPASS_REGEX)) {
|
||||
map2.put(xmlPullParser.getName(), Double.valueOf(Double.parseDouble(xmlPullParser.nextText())));
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlGroundOverlay(imageUrl, createLatLngBounds((Double) map2.get("north"), (Double) map2.get("south"), (Double) map2.get("east"), (Double) map2.get("west")), f, i, map, rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static float getRotation(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
return -Float.parseFloat(xmlPullParser.nextText());
|
||||
}
|
||||
|
||||
private static String getImageUrl(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("Icon")) {
|
||||
return null;
|
||||
}
|
||||
if (eventType == 2 && xmlPullParser.getName().equals("href")) {
|
||||
return xmlPullParser.nextText();
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static Geometry createGeometry(XmlPullParser xmlPullParser, String str) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals(str)) {
|
||||
return null;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals("Point")) {
|
||||
return createPoint(xmlPullParser);
|
||||
}
|
||||
if (xmlPullParser.getName().equals("LineString")) {
|
||||
return createLineString(xmlPullParser);
|
||||
}
|
||||
if (xmlPullParser.getName().equals("Track")) {
|
||||
return createTrack(xmlPullParser);
|
||||
}
|
||||
if (xmlPullParser.getName().equals(KmlPolygon.GEOMETRY_TYPE)) {
|
||||
return createPolygon(xmlPullParser);
|
||||
}
|
||||
if (xmlPullParser.getName().equals("MultiGeometry")) {
|
||||
return createMultiGeometry(xmlPullParser);
|
||||
}
|
||||
if (xmlPullParser.getName().equals("MultiTrack")) {
|
||||
return createMultiTrack(xmlPullParser);
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static HashMap<String, String> setExtendedDataProperties(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
String attributeValue = null;
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals(EXTENDED_DATA)) {
|
||||
return map;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals("Data")) {
|
||||
attributeValue = xmlPullParser.getAttributeValue(null, "name");
|
||||
} else if (xmlPullParser.getName().equals("value") && attributeValue != null) {
|
||||
map.put(attributeValue, xmlPullParser.nextText());
|
||||
attributeValue = null;
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlPoint createPoint(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
LatLngAlt latLngAltConvertToLatLngAlt = null;
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals("Point")) {
|
||||
if (eventType == 2 && xmlPullParser.getName().equals("coordinates")) {
|
||||
latLngAltConvertToLatLngAlt = convertToLatLngAlt(xmlPullParser.nextText());
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlPoint(latLngAltConvertToLatLngAlt.latLng, latLngAltConvertToLatLngAlt.altitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlLineString createLineString(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals("LineString")) {
|
||||
if (eventType == 2 && xmlPullParser.getName().equals("coordinates")) {
|
||||
for (LatLngAlt latLngAlt : convertToLatLngAltArray(xmlPullParser.nextText())) {
|
||||
arrayList.add(latLngAlt.latLng);
|
||||
if (latLngAlt.altitude != null) {
|
||||
arrayList2.add(latLngAlt.altitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlLineString(arrayList, arrayList2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlTrack createTrack(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault());
|
||||
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
ArrayList arrayList3 = new ArrayList();
|
||||
HashMap map = new HashMap();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals("Track")) {
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals("coord")) {
|
||||
LatLngAlt latLngAltConvertToLatLngAlt = convertToLatLngAlt(xmlPullParser.nextText(), " ");
|
||||
arrayList.add(latLngAltConvertToLatLngAlt.latLng);
|
||||
if (latLngAltConvertToLatLngAlt.altitude != null) {
|
||||
arrayList2.add(latLngAltConvertToLatLngAlt.altitude);
|
||||
}
|
||||
} else if (xmlPullParser.getName().equals("when")) {
|
||||
try {
|
||||
arrayList3.add(Long.valueOf(simpleDateFormat.parse(xmlPullParser.nextText()).getTime()));
|
||||
} catch (ParseException e) {
|
||||
throw new XmlPullParserException("Invalid date", xmlPullParser, e);
|
||||
}
|
||||
} else if (xmlPullParser.getName().equals(EXTENDED_DATA)) {
|
||||
map.putAll(setExtendedDataProperties(xmlPullParser));
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlTrack(arrayList, arrayList2, arrayList3, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlPolygon createPolygon(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
ArrayList<LatLng> arrayList = new ArrayList<>();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
boolean zEquals = false;
|
||||
while (true) {
|
||||
if (eventType != 3 || !xmlPullParser.getName().equals(KmlPolygon.GEOMETRY_TYPE)) {
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().matches(BOUNDARY_REGEX)) {
|
||||
zEquals = xmlPullParser.getName().equals("outerBoundaryIs");
|
||||
} else if (xmlPullParser.getName().equals("coordinates")) {
|
||||
if (zEquals) {
|
||||
arrayList = convertToLatLngArray(xmlPullParser.nextText());
|
||||
} else {
|
||||
arrayList2.add(convertToLatLngArray(xmlPullParser.nextText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlPolygon(arrayList, arrayList2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlMultiGeometry createMultiGeometry(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int next = xmlPullParser.next();
|
||||
while (true) {
|
||||
if (next != 3 || !xmlPullParser.getName().equals("MultiGeometry")) {
|
||||
if (next == 2 && xmlPullParser.getName().matches(GEOMETRY_REGEX)) {
|
||||
arrayList.add(createGeometry(xmlPullParser, xmlPullParser.getName()));
|
||||
}
|
||||
next = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlMultiGeometry(arrayList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlMultiTrack createMultiTrack(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int next = xmlPullParser.next();
|
||||
while (true) {
|
||||
if (next != 3 || !xmlPullParser.getName().equals("MultiTrack")) {
|
||||
if (next == 2 && xmlPullParser.getName().matches("Track")) {
|
||||
arrayList.add(createTrack(xmlPullParser));
|
||||
}
|
||||
next = xmlPullParser.next();
|
||||
} else {
|
||||
return new KmlMultiTrack(arrayList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<LatLng> convertToLatLngArray(String str) {
|
||||
ArrayList<LatLngAlt> arrayListConvertToLatLngAltArray = convertToLatLngAltArray(str);
|
||||
ArrayList<LatLng> arrayList = new ArrayList<>();
|
||||
Iterator<LatLngAlt> it = arrayListConvertToLatLngAltArray.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(it.next().latLng);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static ArrayList<LatLngAlt> convertToLatLngAltArray(String str) {
|
||||
ArrayList<LatLngAlt> arrayList = new ArrayList<>();
|
||||
for (String str2 : str.trim().split("(\\s+)")) {
|
||||
arrayList.add(convertToLatLngAlt(str2));
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static LatLngAlt convertToLatLngAlt(String str) {
|
||||
return convertToLatLngAlt(str, LAT_LNG_ALT_SEPARATOR);
|
||||
}
|
||||
|
||||
private static LatLngAlt convertToLatLngAlt(String str, String str2) {
|
||||
String[] strArrSplit = str.split(str2);
|
||||
return new LatLngAlt(new LatLng(Double.parseDouble(strArrSplit[1]), Double.parseDouble(strArrSplit[0])), strArrSplit.length > 2 ? Double.valueOf(Double.parseDouble(strArrSplit[2])) : null);
|
||||
}
|
||||
|
||||
private static LatLngBounds createLatLngBounds(Double d, Double d2, Double d3, Double d4) {
|
||||
return new LatLngBounds(new LatLng(d2.doubleValue(), d4.doubleValue()), new LatLng(d.doubleValue(), d3.doubleValue()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.GroundOverlayOptions;
|
||||
import com.google.android.gms.maps.model.LatLngBounds;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlGroundOverlay {
|
||||
private final GroundOverlayOptions mGroundOverlayOptions;
|
||||
private String mImageUrl;
|
||||
private LatLngBounds mLatLngBox;
|
||||
private final Map<String, String> mProperties;
|
||||
|
||||
KmlGroundOverlay(String str, LatLngBounds latLngBounds, float f, int i, HashMap<String, String> map, float f2) {
|
||||
GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions();
|
||||
this.mGroundOverlayOptions = groundOverlayOptions;
|
||||
this.mImageUrl = str;
|
||||
this.mProperties = map;
|
||||
if (latLngBounds == null) {
|
||||
throw new IllegalArgumentException("No LatLonBox given");
|
||||
}
|
||||
this.mLatLngBox = latLngBounds;
|
||||
groundOverlayOptions.positionFromBounds(latLngBounds);
|
||||
groundOverlayOptions.bearing(f2);
|
||||
groundOverlayOptions.zIndex(f);
|
||||
groundOverlayOptions.visible(i != 0);
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return this.mImageUrl;
|
||||
}
|
||||
|
||||
public LatLngBounds getLatLngBox() {
|
||||
return this.mLatLngBox;
|
||||
}
|
||||
|
||||
public Iterable<String> getProperties() {
|
||||
return this.mProperties.keySet();
|
||||
}
|
||||
|
||||
public String getProperty(String str) {
|
||||
return this.mProperties.get(str);
|
||||
}
|
||||
|
||||
public boolean hasProperty(String str) {
|
||||
return this.mProperties.get(str) != null;
|
||||
}
|
||||
|
||||
GroundOverlayOptions getGroundOverlayOptions() {
|
||||
return this.mGroundOverlayOptions;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("GroundOverlay{\n properties=");
|
||||
sb.append(this.mProperties);
|
||||
sb.append(",\n image url=").append(this.mImageUrl);
|
||||
sb.append(",\n LatLngBox=").append(this.mLatLngBox);
|
||||
sb.append("\n}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.maps.android.collections.GroundOverlayManager;
|
||||
import com.google.maps.android.collections.MarkerManager;
|
||||
import com.google.maps.android.collections.PolygonManager;
|
||||
import com.google.maps.android.collections.PolylineManager;
|
||||
import com.google.maps.android.data.Layer;
|
||||
import com.google.maps.android.data.Renderer;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlLayer extends Layer {
|
||||
public KmlLayer(GoogleMap googleMap, int i, Context context) throws XmlPullParserException, IOException {
|
||||
this(googleMap, context.getResources().openRawResource(i), context, new MarkerManager(googleMap), new PolygonManager(googleMap), new PolylineManager(googleMap), new GroundOverlayManager(googleMap), (Renderer.ImagesCache) null);
|
||||
}
|
||||
|
||||
public KmlLayer(GoogleMap googleMap, InputStream inputStream, Context context) throws XmlPullParserException, IOException {
|
||||
this(googleMap, inputStream, context, new MarkerManager(googleMap), new PolygonManager(googleMap), new PolylineManager(googleMap), new GroundOverlayManager(googleMap), (Renderer.ImagesCache) null);
|
||||
}
|
||||
|
||||
public KmlLayer(GoogleMap googleMap, int i, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager, Renderer.ImagesCache imagesCache) throws XmlPullParserException, IOException {
|
||||
this(googleMap, context.getResources().openRawResource(i), context, markerManager, polygonManager, polylineManager, groundOverlayManager, imagesCache);
|
||||
}
|
||||
|
||||
public KmlLayer(GoogleMap googleMap, InputStream inputStream, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager, Renderer.ImagesCache imagesCache) throws Throwable {
|
||||
if (inputStream == null) {
|
||||
throw new IllegalArgumentException("KML InputStream cannot be null");
|
||||
}
|
||||
KmlRenderer kmlRenderer = new KmlRenderer(googleMap, context, markerManager, polygonManager, polylineManager, groundOverlayManager, imagesCache);
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
bufferedInputStream.mark(1024);
|
||||
ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream);
|
||||
try {
|
||||
ZipEntry nextEntry = zipInputStream.getNextEntry();
|
||||
if (nextEntry != null) {
|
||||
HashMap<String, Bitmap> map = new HashMap<>();
|
||||
KmlParser kml = null;
|
||||
while (nextEntry != null) {
|
||||
if (kml == null && nextEntry.getName().toLowerCase().endsWith(".kml")) {
|
||||
kml = parseKml(zipInputStream);
|
||||
} else {
|
||||
Bitmap bitmapDecodeStream = BitmapFactory.decodeStream(zipInputStream);
|
||||
if (bitmapDecodeStream != null) {
|
||||
map.put(nextEntry.getName(), bitmapDecodeStream);
|
||||
} else {
|
||||
Log.w("KmlLayer", "Unsupported KMZ contents file type: " + nextEntry.getName());
|
||||
}
|
||||
}
|
||||
nextEntry = zipInputStream.getNextEntry();
|
||||
}
|
||||
if (kml == null) {
|
||||
throw new IllegalArgumentException("KML not found in InputStream");
|
||||
}
|
||||
kmlRenderer.storeKmzData(kml.getStyles(), kml.getStyleMaps(), kml.getPlacemarks(), kml.getContainers(), kml.getGroundOverlays(), map);
|
||||
} else {
|
||||
bufferedInputStream.reset();
|
||||
KmlParser kml2 = parseKml(bufferedInputStream);
|
||||
kmlRenderer.storeKmlData(kml2.getStyles(), kml2.getStyleMaps(), kml2.getPlacemarks(), kml2.getContainers(), kml2.getGroundOverlays());
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
}
|
||||
try {
|
||||
storeRenderer(kmlRenderer);
|
||||
inputStream.close();
|
||||
bufferedInputStream.close();
|
||||
zipInputStream.close();
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
inputStream.close();
|
||||
bufferedInputStream.close();
|
||||
zipInputStream.close();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
private static KmlParser parseKml(InputStream inputStream) throws XmlPullParserException, IOException {
|
||||
KmlParser kmlParser = new KmlParser(createXmlParser(inputStream));
|
||||
kmlParser.parseKml();
|
||||
return kmlParser;
|
||||
}
|
||||
|
||||
private static XmlPullParser createXmlParser(InputStream inputStream) throws XmlPullParserException {
|
||||
XmlPullParserFactory xmlPullParserFactoryNewInstance = XmlPullParserFactory.newInstance();
|
||||
xmlPullParserFactoryNewInstance.setNamespaceAware(true);
|
||||
XmlPullParser xmlPullParserNewPullParser = xmlPullParserFactoryNewInstance.newPullParser();
|
||||
xmlPullParserNewPullParser.setInput(inputStream, null);
|
||||
return xmlPullParserNewPullParser;
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Layer
|
||||
public void addLayerToMap() {
|
||||
super.addKMLToMap();
|
||||
}
|
||||
|
||||
public boolean hasPlacemarks() {
|
||||
return hasFeatures();
|
||||
}
|
||||
|
||||
public Iterable<KmlPlacemark> getPlacemarks() {
|
||||
return getFeatures();
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Layer
|
||||
public boolean hasContainers() {
|
||||
return super.hasContainers();
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Layer
|
||||
public Iterable<KmlContainer> getContainers() {
|
||||
return super.getContainers();
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Layer
|
||||
public Iterable<KmlGroundOverlay> getGroundOverlays() {
|
||||
return super.getGroundOverlays();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.maps.android.data.LineString;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlLineString extends LineString {
|
||||
private final ArrayList<Double> mAltitudes;
|
||||
|
||||
public KmlLineString(ArrayList<LatLng> arrayList) {
|
||||
this(arrayList, null);
|
||||
}
|
||||
|
||||
public KmlLineString(ArrayList<LatLng> arrayList, ArrayList<Double> arrayList2) {
|
||||
super(arrayList);
|
||||
this.mAltitudes = arrayList2;
|
||||
}
|
||||
|
||||
public ArrayList<Double> getAltitudes() {
|
||||
return this.mAltitudes;
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.LineString, com.google.maps.android.data.Geometry
|
||||
public List<LatLng> getGeometryObject() {
|
||||
return new ArrayList(super.getGeometryObject());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.maps.android.data.Geometry;
|
||||
import com.google.maps.android.data.MultiGeometry;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlMultiGeometry extends MultiGeometry {
|
||||
public KmlMultiGeometry(ArrayList<Geometry> arrayList) {
|
||||
super(arrayList);
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.MultiGeometry, com.google.maps.android.data.Geometry
|
||||
public ArrayList<Geometry> getGeometryObject() {
|
||||
return new ArrayList<>(super.getGeometryObject());
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.MultiGeometry
|
||||
public String toString() {
|
||||
StringBuilder sbAppend = new StringBuilder(getGeometryType()).append("{\n geometries=");
|
||||
sbAppend.append(getGeometryObject());
|
||||
sbAppend.append("\n}\n");
|
||||
return sbAppend.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.maps.android.data.Geometry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlMultiTrack extends KmlMultiGeometry {
|
||||
public KmlMultiTrack(ArrayList<KmlTrack> arrayList) {
|
||||
super(createGeometries(arrayList));
|
||||
}
|
||||
|
||||
private static ArrayList<Geometry> createGeometries(ArrayList<KmlTrack> arrayList) {
|
||||
ArrayList<Geometry> arrayList2 = new ArrayList<>();
|
||||
if (arrayList == null) {
|
||||
throw new IllegalArgumentException("Tracks cannot be null");
|
||||
}
|
||||
Iterator<KmlTrack> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList2.add(it.next());
|
||||
}
|
||||
return arrayList2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.GroundOverlay;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
class KmlParser {
|
||||
private static final String CONTAINER_REGEX = "Folder|Document";
|
||||
private static final String GROUND_OVERLAY = "GroundOverlay";
|
||||
private static final String PLACEMARK = "Placemark";
|
||||
private static final String STYLE = "Style";
|
||||
private static final String STYLE_MAP = "StyleMap";
|
||||
private static final String UNSUPPORTED_REGEX = "altitude|altitudeModeGroup|altitudeMode|begin|bottomFov|cookie|displayName|displayMode|end|expires|extrude|flyToView|gridOrigin|httpQuery|leftFov|linkDescription|linkName|linkSnippet|listItemType|maxSnippetLines|maxSessionLength|message|minAltitude|minFadeExtent|minLodPixels|minRefreshPeriod|maxAltitude|maxFadeExtent|maxLodPixels|maxHeight|maxWidth|near|NetworkLink|NetworkLinkControl|overlayXY|range|refreshMode|refreshInterval|refreshVisibility|rightFov|roll|rotationXY|screenXY|shape|sourceHref|state|targetHref|tessellate|tileSize|topFov|viewBoundScale|viewFormat|viewRefreshMode|viewRefreshTime|when";
|
||||
private final XmlPullParser mParser;
|
||||
private final HashMap<KmlPlacemark, Object> mPlacemarks = new HashMap<>();
|
||||
private final ArrayList<KmlContainer> mContainers = new ArrayList<>();
|
||||
private final HashMap<String, KmlStyle> mStyles = new HashMap<>();
|
||||
private final HashMap<String, String> mStyleMaps = new HashMap<>();
|
||||
private final HashMap<KmlGroundOverlay, GroundOverlay> mGroundOverlays = new HashMap<>();
|
||||
|
||||
KmlParser(XmlPullParser xmlPullParser) {
|
||||
this.mParser = xmlPullParser;
|
||||
}
|
||||
|
||||
void parseKml() throws XmlPullParserException, IOException {
|
||||
int eventType = this.mParser.getEventType();
|
||||
while (eventType != 1) {
|
||||
if (eventType == 2) {
|
||||
if (this.mParser.getName().matches(UNSUPPORTED_REGEX)) {
|
||||
skip(this.mParser);
|
||||
}
|
||||
if (this.mParser.getName().matches(CONTAINER_REGEX)) {
|
||||
this.mContainers.add(KmlContainerParser.createContainer(this.mParser));
|
||||
}
|
||||
if (this.mParser.getName().equals(STYLE)) {
|
||||
KmlStyle kmlStyleCreateStyle = KmlStyleParser.createStyle(this.mParser);
|
||||
this.mStyles.put(kmlStyleCreateStyle.getStyleId(), kmlStyleCreateStyle);
|
||||
}
|
||||
if (this.mParser.getName().equals(STYLE_MAP)) {
|
||||
this.mStyleMaps.putAll(KmlStyleParser.createStyleMap(this.mParser));
|
||||
}
|
||||
if (this.mParser.getName().equals(PLACEMARK)) {
|
||||
this.mPlacemarks.put(KmlFeatureParser.createPlacemark(this.mParser), null);
|
||||
}
|
||||
if (this.mParser.getName().equals(GROUND_OVERLAY)) {
|
||||
this.mGroundOverlays.put(KmlFeatureParser.createGroundOverlay(this.mParser), null);
|
||||
}
|
||||
}
|
||||
eventType = this.mParser.next();
|
||||
}
|
||||
this.mStyles.put(null, new KmlStyle());
|
||||
}
|
||||
|
||||
HashMap<String, KmlStyle> getStyles() {
|
||||
return this.mStyles;
|
||||
}
|
||||
|
||||
HashMap<KmlPlacemark, Object> getPlacemarks() {
|
||||
return this.mPlacemarks;
|
||||
}
|
||||
|
||||
HashMap<String, String> getStyleMaps() {
|
||||
return this.mStyleMaps;
|
||||
}
|
||||
|
||||
ArrayList<KmlContainer> getContainers() {
|
||||
return this.mContainers;
|
||||
}
|
||||
|
||||
HashMap<KmlGroundOverlay, GroundOverlay> getGroundOverlays() {
|
||||
return this.mGroundOverlays;
|
||||
}
|
||||
|
||||
static void skip(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
if (xmlPullParser.getEventType() != 2) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
int i = 1;
|
||||
while (i != 0) {
|
||||
int next = xmlPullParser.next();
|
||||
if (next == 2) {
|
||||
i++;
|
||||
} else if (next == 3) {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.PolygonOptions;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.maps.android.data.Feature;
|
||||
import com.google.maps.android.data.Geometry;
|
||||
import java.util.Map;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlPlacemark extends Feature {
|
||||
private final KmlStyle mInlineStyle;
|
||||
private final String mStyle;
|
||||
|
||||
public KmlPlacemark(Geometry geometry, String str, KmlStyle kmlStyle, Map<String, String> map) {
|
||||
super(geometry, str, map);
|
||||
this.mStyle = str;
|
||||
this.mInlineStyle = kmlStyle;
|
||||
}
|
||||
|
||||
public String getStyleId() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
public KmlStyle getInlineStyle() {
|
||||
return this.mInlineStyle;
|
||||
}
|
||||
|
||||
public PolygonOptions getPolygonOptions() {
|
||||
KmlStyle kmlStyle = this.mInlineStyle;
|
||||
if (kmlStyle == null) {
|
||||
return null;
|
||||
}
|
||||
return kmlStyle.getPolygonOptions();
|
||||
}
|
||||
|
||||
public MarkerOptions getMarkerOptions() {
|
||||
KmlStyle kmlStyle = this.mInlineStyle;
|
||||
if (kmlStyle == null) {
|
||||
return null;
|
||||
}
|
||||
return kmlStyle.getMarkerOptions();
|
||||
}
|
||||
|
||||
public PolylineOptions getPolylineOptions() {
|
||||
KmlStyle kmlStyle = this.mInlineStyle;
|
||||
if (kmlStyle == null) {
|
||||
return null;
|
||||
}
|
||||
return kmlStyle.getPolylineOptions();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("Placemark{\n style id=");
|
||||
sb.append(this.mStyle);
|
||||
sb.append(",\n inline style=").append(this.mInlineStyle);
|
||||
sb.append("\n}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.maps.android.data.Point;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlPoint extends Point {
|
||||
private final Double mAltitude;
|
||||
|
||||
public KmlPoint(LatLng latLng) {
|
||||
this(latLng, null);
|
||||
}
|
||||
|
||||
public KmlPoint(LatLng latLng, Double d) {
|
||||
super(latLng);
|
||||
this.mAltitude = d;
|
||||
}
|
||||
|
||||
public Double getAltitude() {
|
||||
return this.mAltitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.maps.android.data.DataPolygon;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> {
|
||||
public static final String GEOMETRY_TYPE = "Polygon";
|
||||
private final List<List<LatLng>> mInnerBoundaryCoordinates;
|
||||
private final List<LatLng> mOuterBoundaryCoordinates;
|
||||
|
||||
public KmlPolygon(List<LatLng> list, List<List<LatLng>> list2) {
|
||||
if (list == null) {
|
||||
throw new IllegalArgumentException("Outer boundary coordinates cannot be null");
|
||||
}
|
||||
this.mOuterBoundaryCoordinates = list;
|
||||
this.mInnerBoundaryCoordinates = list2;
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Geometry
|
||||
public String getGeometryType() {
|
||||
return GEOMETRY_TYPE;
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Geometry
|
||||
public List<List<LatLng>> getGeometryObject() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(this.mOuterBoundaryCoordinates);
|
||||
List<List<LatLng>> list = this.mInnerBoundaryCoordinates;
|
||||
if (list != null) {
|
||||
arrayList.addAll(list);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.DataPolygon
|
||||
public List<LatLng> getOuterBoundaryCoordinates() {
|
||||
return this.mOuterBoundaryCoordinates;
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.DataPolygon
|
||||
public List<List<LatLng>> getInnerBoundaryCoordinates() {
|
||||
return this.mInnerBoundaryCoordinates;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("Polygon{\n outer coordinates=");
|
||||
sb.append(this.mOuterBoundaryCoordinates);
|
||||
sb.append(",\n inner coordinates=").append(this.mInnerBoundaryCoordinates);
|
||||
sb.append("\n}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptor;
|
||||
import com.google.android.gms.maps.model.GroundOverlay;
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.maps.android.collections.GroundOverlayManager;
|
||||
import com.google.maps.android.collections.MarkerManager;
|
||||
import com.google.maps.android.collections.PolygonManager;
|
||||
import com.google.maps.android.collections.PolylineManager;
|
||||
import com.google.maps.android.data.Feature;
|
||||
import com.google.maps.android.data.Geometry;
|
||||
import com.google.maps.android.data.MultiGeometry;
|
||||
import com.google.maps.android.data.Renderer;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlRenderer extends Renderer {
|
||||
private static final String LOG_TAG = "KmlRenderer";
|
||||
private ArrayList<KmlContainer> mContainers;
|
||||
private boolean mGroundOverlayImagesDownloaded;
|
||||
private final Set<String> mGroundOverlayUrls;
|
||||
private boolean mMarkerIconsDownloaded;
|
||||
|
||||
KmlRenderer(GoogleMap googleMap, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager, Renderer.ImagesCache imagesCache) {
|
||||
super(googleMap, context, markerManager, polygonManager, polylineManager, groundOverlayManager, imagesCache);
|
||||
this.mGroundOverlayUrls = new HashSet();
|
||||
this.mMarkerIconsDownloaded = false;
|
||||
this.mGroundOverlayImagesDownloaded = false;
|
||||
}
|
||||
|
||||
private void removePlacemarks(HashMap<? extends Feature, Object> map) {
|
||||
removeFeatures(map);
|
||||
}
|
||||
|
||||
static boolean getContainerVisibility(KmlContainer kmlContainer, boolean z) {
|
||||
return z && (!kmlContainer.hasProperty("visibility") || Integer.parseInt(kmlContainer.getProperty("visibility")) != 0);
|
||||
}
|
||||
|
||||
private void removeContainers(Iterable<KmlContainer> iterable) {
|
||||
for (KmlContainer kmlContainer : iterable) {
|
||||
removePlacemarks(kmlContainer.getPlacemarksHashMap());
|
||||
removeGroundOverlays(kmlContainer.getGroundOverlayHashMap());
|
||||
removeContainers(kmlContainer.getContainers());
|
||||
}
|
||||
}
|
||||
|
||||
public void addLayerToMap() {
|
||||
setLayerVisibility(true);
|
||||
this.mContainers = getContainerList();
|
||||
putStyles();
|
||||
assignStyleMap(getStyleMaps(), getStylesRenderer());
|
||||
addGroundOverlays(getGroundOverlayMap(), this.mContainers);
|
||||
addContainerGroupToMap(this.mContainers, true);
|
||||
addPlacemarksToMap(getAllFeatures());
|
||||
if (!this.mGroundOverlayImagesDownloaded) {
|
||||
downloadGroundOverlays();
|
||||
}
|
||||
if (!this.mMarkerIconsDownloaded) {
|
||||
downloadMarkerIcons();
|
||||
}
|
||||
checkClearBitmapCache();
|
||||
}
|
||||
|
||||
void storeKmlData(HashMap<String, KmlStyle> map, HashMap<String, String> map2, HashMap<KmlPlacemark, Object> map3, ArrayList<KmlContainer> arrayList, HashMap<KmlGroundOverlay, GroundOverlay> map4) {
|
||||
storeData(map, map2, map3, arrayList, map4);
|
||||
}
|
||||
|
||||
void storeKmzData(HashMap<String, KmlStyle> map, HashMap<String, String> map2, HashMap<KmlPlacemark, Object> map3, ArrayList<KmlContainer> arrayList, HashMap<KmlGroundOverlay, GroundOverlay> map4, HashMap<String, Bitmap> map5) {
|
||||
storeData(map, map2, map3, arrayList, map4);
|
||||
for (Map.Entry<String, Bitmap> entry : map5.entrySet()) {
|
||||
cacheBitmap(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.maps.android.data.Renderer
|
||||
public void setMap(GoogleMap googleMap) {
|
||||
removeLayerFromMap();
|
||||
super.setMap(googleMap);
|
||||
addLayerToMap();
|
||||
}
|
||||
|
||||
boolean hasKmlPlacemarks() {
|
||||
return hasFeatures();
|
||||
}
|
||||
|
||||
Iterable<? extends Feature> getKmlPlacemarks() {
|
||||
return getFeatures();
|
||||
}
|
||||
|
||||
public boolean hasNestedContainers() {
|
||||
return this.mContainers.size() > 0;
|
||||
}
|
||||
|
||||
public Iterable<KmlContainer> getNestedContainers() {
|
||||
return this.mContainers;
|
||||
}
|
||||
|
||||
public Iterable<KmlGroundOverlay> getGroundOverlays() {
|
||||
return getGroundOverlayMap().keySet();
|
||||
}
|
||||
|
||||
public void removeLayerFromMap() {
|
||||
removePlacemarks(getAllFeatures());
|
||||
removeGroundOverlays(getGroundOverlayMap());
|
||||
if (hasNestedContainers()) {
|
||||
removeContainers(getNestedContainers());
|
||||
}
|
||||
setLayerVisibility(false);
|
||||
clearStylesRenderer();
|
||||
}
|
||||
|
||||
private void addPlacemarksToMap(HashMap<? extends Feature, Object> map) {
|
||||
Iterator<? extends Feature> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
addFeature(it.next());
|
||||
}
|
||||
}
|
||||
|
||||
private void addContainerGroupToMap(Iterable<KmlContainer> iterable, boolean z) {
|
||||
for (KmlContainer kmlContainer : iterable) {
|
||||
boolean containerVisibility = getContainerVisibility(kmlContainer, z);
|
||||
if (kmlContainer.getStyles() != null) {
|
||||
putStyles(kmlContainer.getStyles());
|
||||
}
|
||||
if (kmlContainer.getStyleMap() != null) {
|
||||
super.assignStyleMap(kmlContainer.getStyleMap(), getStylesRenderer());
|
||||
}
|
||||
addContainerObjectToMap(kmlContainer, containerVisibility);
|
||||
if (kmlContainer.hasContainers()) {
|
||||
addContainerGroupToMap(kmlContainer.getContainers(), containerVisibility);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addContainerObjectToMap(KmlContainer kmlContainer, boolean z) {
|
||||
for (KmlPlacemark kmlPlacemark : kmlContainer.getPlacemarks()) {
|
||||
boolean z2 = z && getPlacemarkVisibility(kmlPlacemark);
|
||||
if (kmlPlacemark.getGeometry() != null) {
|
||||
String id = kmlPlacemark.getId();
|
||||
Geometry geometry = kmlPlacemark.getGeometry();
|
||||
KmlStyle placemarkStyle = getPlacemarkStyle(id);
|
||||
KmlPlacemark kmlPlacemark2 = kmlPlacemark;
|
||||
Object objAddKmlPlacemarkToMap = addKmlPlacemarkToMap(kmlPlacemark2, geometry, placemarkStyle, kmlPlacemark2.getInlineStyle(), z2);
|
||||
kmlContainer.setPlacemark(kmlPlacemark2, objAddKmlPlacemarkToMap);
|
||||
putContainerFeature(objAddKmlPlacemarkToMap, kmlPlacemark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadMarkerIcons() {
|
||||
this.mMarkerIconsDownloaded = true;
|
||||
Iterator<String> it = getMarkerIconUrls().iterator();
|
||||
while (it.hasNext()) {
|
||||
new MarkerIconImageDownload(it.next()).execute(new String[0]);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void addIconToMarkers(String str, HashMap<KmlPlacemark, Object> map) {
|
||||
for (KmlPlacemark kmlPlacemark : map.keySet()) {
|
||||
addIconToGeometry(str, getStylesRenderer().get(kmlPlacemark.getId()), kmlPlacemark.getInlineStyle(), kmlPlacemark.getGeometry(), map.get(kmlPlacemark));
|
||||
}
|
||||
}
|
||||
|
||||
private void addIconToGeometry(String str, KmlStyle kmlStyle, KmlStyle kmlStyle2, Geometry geometry, Object obj) {
|
||||
if (geometry == null) {
|
||||
return;
|
||||
}
|
||||
if ("Point".equals(geometry.getGeometryType())) {
|
||||
addIconToMarker(str, kmlStyle, kmlStyle2, (Marker) obj);
|
||||
} else if ("MultiGeometry".equals(geometry.getGeometryType())) {
|
||||
addIconToMultiGeometry(str, kmlStyle, kmlStyle2, (MultiGeometry) geometry, (List) obj);
|
||||
}
|
||||
}
|
||||
|
||||
private void addIconToMultiGeometry(String str, KmlStyle kmlStyle, KmlStyle kmlStyle2, MultiGeometry multiGeometry, List<Object> list) {
|
||||
Iterator<Geometry> it = multiGeometry.getGeometryObject().iterator();
|
||||
Iterator<Object> it2 = list.iterator();
|
||||
while (it.hasNext() && it2.hasNext()) {
|
||||
addIconToGeometry(str, kmlStyle, kmlStyle2, it.next(), it2.next());
|
||||
}
|
||||
}
|
||||
|
||||
private void addIconToMarker(String str, KmlStyle kmlStyle, KmlStyle kmlStyle2, Marker marker) {
|
||||
boolean z = kmlStyle2 != null && str.equals(kmlStyle2.getIconUrl());
|
||||
boolean z2 = kmlStyle != null && str.equals(kmlStyle.getIconUrl());
|
||||
if (z) {
|
||||
scaleBitmap(kmlStyle2, marker);
|
||||
} else if (z2) {
|
||||
scaleBitmap(kmlStyle, marker);
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleBitmap(KmlStyle kmlStyle, Marker marker) {
|
||||
marker.setIcon(getCachedMarkerImage(kmlStyle.getIconUrl(), kmlStyle.getIconScale()));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void addContainerGroupIconsToMarkers(String str, Iterable<KmlContainer> iterable) {
|
||||
for (KmlContainer kmlContainer : iterable) {
|
||||
addIconToMarkers(str, kmlContainer.getPlacemarksHashMap());
|
||||
if (kmlContainer.hasContainers()) {
|
||||
addContainerGroupIconsToMarkers(str, kmlContainer.getContainers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addGroundOverlays(HashMap<KmlGroundOverlay, GroundOverlay> map, Iterable<KmlContainer> iterable) {
|
||||
addGroundOverlays(map);
|
||||
for (KmlContainer kmlContainer : iterable) {
|
||||
addGroundOverlays(kmlContainer.getGroundOverlayHashMap(), kmlContainer.getContainers());
|
||||
}
|
||||
}
|
||||
|
||||
private void addGroundOverlays(HashMap<KmlGroundOverlay, GroundOverlay> map) {
|
||||
for (KmlGroundOverlay kmlGroundOverlay : map.keySet()) {
|
||||
String imageUrl = kmlGroundOverlay.getImageUrl();
|
||||
if (imageUrl != null && kmlGroundOverlay.getLatLngBox() != null) {
|
||||
if (getCachedGroundOverlayImage(imageUrl) != null) {
|
||||
addGroundOverlayToMap(imageUrl, map, true);
|
||||
} else {
|
||||
this.mGroundOverlayUrls.add(imageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadGroundOverlays() {
|
||||
this.mGroundOverlayImagesDownloaded = true;
|
||||
Iterator<String> it = this.mGroundOverlayUrls.iterator();
|
||||
while (it.hasNext()) {
|
||||
new GroundOverlayImageDownload(it.next()).execute(new String[0]);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void addGroundOverlayToMap(String str, HashMap<KmlGroundOverlay, GroundOverlay> map, boolean z) {
|
||||
BitmapDescriptor cachedGroundOverlayImage = getCachedGroundOverlayImage(str);
|
||||
for (KmlGroundOverlay kmlGroundOverlay : map.keySet()) {
|
||||
if (kmlGroundOverlay.getImageUrl().equals(str)) {
|
||||
GroundOverlay groundOverlayAttachGroundOverlay = attachGroundOverlay(kmlGroundOverlay.getGroundOverlayOptions().image(cachedGroundOverlayImage));
|
||||
if (!z) {
|
||||
groundOverlayAttachGroundOverlay.setVisible(false);
|
||||
}
|
||||
map.put(kmlGroundOverlay, groundOverlayAttachGroundOverlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void addGroundOverlayInContainerGroups(String str, Iterable<KmlContainer> iterable, boolean z) {
|
||||
for (KmlContainer kmlContainer : iterable) {
|
||||
boolean containerVisibility = getContainerVisibility(kmlContainer, z);
|
||||
addGroundOverlayToMap(str, kmlContainer.getGroundOverlayHashMap(), containerVisibility);
|
||||
if (kmlContainer.hasContainers()) {
|
||||
addGroundOverlayInContainerGroups(str, kmlContainer.getContainers(), containerVisibility);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MarkerIconImageDownload extends AsyncTask<String, Void, Bitmap> {
|
||||
private final String mIconUrl;
|
||||
|
||||
public MarkerIconImageDownload(String str) {
|
||||
this.mIconUrl = str;
|
||||
KmlRenderer.this.downloadStarted();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public Bitmap doInBackground(String... strArr) {
|
||||
try {
|
||||
return KmlRenderer.this.getBitmapFromUrl(this.mIconUrl);
|
||||
} catch (MalformedURLException unused) {
|
||||
return BitmapFactory.decodeFile(this.mIconUrl);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public void onPostExecute(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
KmlRenderer.this.cacheBitmap(this.mIconUrl, bitmap);
|
||||
if (KmlRenderer.this.isLayerOnMap()) {
|
||||
KmlRenderer kmlRenderer = KmlRenderer.this;
|
||||
kmlRenderer.addIconToMarkers(this.mIconUrl, kmlRenderer.getAllFeatures());
|
||||
KmlRenderer kmlRenderer2 = KmlRenderer.this;
|
||||
kmlRenderer2.addContainerGroupIconsToMarkers(this.mIconUrl, kmlRenderer2.mContainers);
|
||||
}
|
||||
} else {
|
||||
Log.e(KmlRenderer.LOG_TAG, "Image at this URL could not be found " + this.mIconUrl);
|
||||
}
|
||||
KmlRenderer.this.downloadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private class GroundOverlayImageDownload extends AsyncTask<String, Void, Bitmap> {
|
||||
private final String mGroundOverlayUrl;
|
||||
|
||||
public GroundOverlayImageDownload(String str) {
|
||||
this.mGroundOverlayUrl = str;
|
||||
KmlRenderer.this.downloadStarted();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public Bitmap doInBackground(String... strArr) {
|
||||
try {
|
||||
return KmlRenderer.this.getBitmapFromUrl(this.mGroundOverlayUrl);
|
||||
} catch (MalformedURLException unused) {
|
||||
return BitmapFactory.decodeFile(this.mGroundOverlayUrl);
|
||||
} catch (IOException e) {
|
||||
Log.e(KmlRenderer.LOG_TAG, "Image [" + this.mGroundOverlayUrl + "] download issue", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public void onPostExecute(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
KmlRenderer.this.cacheBitmap(this.mGroundOverlayUrl, bitmap);
|
||||
if (KmlRenderer.this.isLayerOnMap()) {
|
||||
KmlRenderer kmlRenderer = KmlRenderer.this;
|
||||
kmlRenderer.addGroundOverlayToMap(this.mGroundOverlayUrl, kmlRenderer.getGroundOverlayMap(), true);
|
||||
KmlRenderer kmlRenderer2 = KmlRenderer.this;
|
||||
kmlRenderer2.addGroundOverlayInContainerGroups(this.mGroundOverlayUrl, kmlRenderer2.mContainers, true);
|
||||
}
|
||||
} else {
|
||||
Log.e(KmlRenderer.LOG_TAG, "Image at this URL could not be found " + this.mGroundOverlayUrl);
|
||||
}
|
||||
KmlRenderer.this.downloadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public Bitmap getBitmapFromUrl(String str) throws IOException {
|
||||
return BitmapFactory.decodeStream(openConnectionCheckRedirects(new URL(str).openConnection()));
|
||||
}
|
||||
|
||||
private InputStream openConnectionCheckRedirects(URLConnection uRLConnection) throws IOException {
|
||||
InputStream inputStream;
|
||||
boolean z;
|
||||
HttpURLConnection httpURLConnection;
|
||||
int responseCode;
|
||||
int i = 0;
|
||||
do {
|
||||
boolean z2 = uRLConnection instanceof HttpURLConnection;
|
||||
if (z2) {
|
||||
((HttpURLConnection) uRLConnection).setInstanceFollowRedirects(false);
|
||||
}
|
||||
inputStream = uRLConnection.getInputStream();
|
||||
if (!z2 || (responseCode = (httpURLConnection = (HttpURLConnection) uRLConnection).getResponseCode()) < 300 || responseCode > 307 || responseCode == 306 || responseCode == 304) {
|
||||
z = false;
|
||||
} else {
|
||||
URL url = httpURLConnection.getURL();
|
||||
String headerField = httpURLConnection.getHeaderField("Location");
|
||||
URL url2 = headerField != null ? new URL(url, headerField) : null;
|
||||
httpURLConnection.disconnect();
|
||||
if (url2 == null || ((!url2.getProtocol().equals("http") && !url2.getProtocol().equals("https")) || i >= 5)) {
|
||||
throw new SecurityException("illegal URL redirect");
|
||||
}
|
||||
uRLConnection = url2.openConnection();
|
||||
i++;
|
||||
z = true;
|
||||
}
|
||||
} while (z);
|
||||
return inputStream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import android.graphics.Color;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.PolygonOptions;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.maps.android.data.Style;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlStyle extends Style {
|
||||
private static final int HSV_VALUES = 3;
|
||||
private static final int HUE_VALUE = 0;
|
||||
private static final int INITIAL_SCALE = 1;
|
||||
private String mIconUrl;
|
||||
private boolean mFill = true;
|
||||
private boolean mOutline = true;
|
||||
private String mStyleId = null;
|
||||
private final HashMap<String, String> mBalloonOptions = new HashMap<>();
|
||||
private final HashSet<String> mStylesSet = new HashSet<>();
|
||||
private double mScale = 1.0d;
|
||||
float mMarkerColor = 0.0f;
|
||||
private boolean mIconRandomColorMode = false;
|
||||
private boolean mLineRandomColorMode = false;
|
||||
private boolean mPolyRandomColorMode = false;
|
||||
|
||||
KmlStyle() {
|
||||
}
|
||||
|
||||
void setInfoWindowText(String str) {
|
||||
this.mBalloonOptions.put("text", str);
|
||||
}
|
||||
|
||||
String getStyleId() {
|
||||
return this.mStyleId;
|
||||
}
|
||||
|
||||
void setStyleId(String str) {
|
||||
this.mStyleId = str;
|
||||
}
|
||||
|
||||
public boolean isStyleSet(String str) {
|
||||
return this.mStylesSet.contains(str);
|
||||
}
|
||||
|
||||
public boolean hasFill() {
|
||||
return this.mFill;
|
||||
}
|
||||
|
||||
public void setFill(boolean z) {
|
||||
this.mFill = z;
|
||||
}
|
||||
|
||||
public double getIconScale() {
|
||||
return this.mScale;
|
||||
}
|
||||
|
||||
void setIconScale(double d) {
|
||||
this.mScale = d;
|
||||
this.mStylesSet.add("iconScale");
|
||||
}
|
||||
|
||||
public boolean hasOutline() {
|
||||
return this.mOutline;
|
||||
}
|
||||
|
||||
public boolean hasBalloonStyle() {
|
||||
return this.mBalloonOptions.size() > 0;
|
||||
}
|
||||
|
||||
void setOutline(boolean z) {
|
||||
this.mOutline = z;
|
||||
this.mStylesSet.add("outline");
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return this.mIconUrl;
|
||||
}
|
||||
|
||||
void setIconUrl(String str) {
|
||||
this.mIconUrl = str;
|
||||
this.mStylesSet.add("iconUrl");
|
||||
}
|
||||
|
||||
void setFillColor(String str) {
|
||||
setPolygonFillColor(Color.parseColor("#" + convertColor(str)));
|
||||
this.mStylesSet.add("fillColor");
|
||||
}
|
||||
|
||||
void setMarkerColor(String str) {
|
||||
this.mMarkerColor = getHueValue(Color.parseColor("#" + convertColor(str)));
|
||||
this.mMarkerOptions.icon(BitmapDescriptorFactory.defaultMarker(this.mMarkerColor));
|
||||
this.mStylesSet.add("markerColor");
|
||||
}
|
||||
|
||||
private static float getHueValue(int i) {
|
||||
float[] fArr = new float[3];
|
||||
Color.colorToHSV(i, fArr);
|
||||
return fArr[0];
|
||||
}
|
||||
|
||||
private static String convertColor(String str) {
|
||||
String strTrim = str.trim();
|
||||
if (strTrim.length() > 6) {
|
||||
return strTrim.substring(0, 2) + strTrim.substring(6, 8) + strTrim.substring(4, 6) + strTrim.substring(2, 4);
|
||||
}
|
||||
return strTrim.substring(4, 6) + strTrim.substring(2, 4) + strTrim.substring(0, 2);
|
||||
}
|
||||
|
||||
void setHeading(float f) {
|
||||
setMarkerRotation(f);
|
||||
this.mStylesSet.add("heading");
|
||||
}
|
||||
|
||||
void setHotSpot(float f, float f2, String str, String str2) {
|
||||
setMarkerHotSpot(f, f2, str, str2);
|
||||
this.mStylesSet.add("hotSpot");
|
||||
}
|
||||
|
||||
void setIconColorMode(String str) {
|
||||
this.mIconRandomColorMode = str.equals("random");
|
||||
this.mStylesSet.add("iconColorMode");
|
||||
}
|
||||
|
||||
boolean isIconRandomColorMode() {
|
||||
return this.mIconRandomColorMode;
|
||||
}
|
||||
|
||||
void setLineColorMode(String str) {
|
||||
this.mLineRandomColorMode = str.equals("random");
|
||||
this.mStylesSet.add("lineColorMode");
|
||||
}
|
||||
|
||||
public boolean isLineRandomColorMode() {
|
||||
return this.mLineRandomColorMode;
|
||||
}
|
||||
|
||||
void setPolyColorMode(String str) {
|
||||
this.mPolyRandomColorMode = str.equals("random");
|
||||
this.mStylesSet.add("polyColorMode");
|
||||
}
|
||||
|
||||
public boolean isPolyRandomColorMode() {
|
||||
return this.mPolyRandomColorMode;
|
||||
}
|
||||
|
||||
void setOutlineColor(String str) {
|
||||
this.mPolylineOptions.color(Color.parseColor("#" + convertColor(str)));
|
||||
this.mPolygonOptions.strokeColor(Color.parseColor("#" + convertColor(str)));
|
||||
this.mStylesSet.add("outlineColor");
|
||||
}
|
||||
|
||||
void setWidth(Float f) {
|
||||
setLineStringWidth(f.floatValue());
|
||||
setPolygonStrokeWidth(f.floatValue());
|
||||
this.mStylesSet.add("width");
|
||||
}
|
||||
|
||||
public HashMap<String, String> getBalloonOptions() {
|
||||
return this.mBalloonOptions;
|
||||
}
|
||||
|
||||
private static MarkerOptions createMarkerOptions(MarkerOptions markerOptions, boolean z, float f) {
|
||||
MarkerOptions markerOptions2 = new MarkerOptions();
|
||||
markerOptions2.rotation(markerOptions.getRotation());
|
||||
markerOptions2.anchor(markerOptions.getAnchorU(), markerOptions.getAnchorV());
|
||||
if (z) {
|
||||
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(getHueValue(computeRandomColor((int) f))));
|
||||
}
|
||||
markerOptions2.icon(markerOptions.getIcon());
|
||||
return markerOptions2;
|
||||
}
|
||||
|
||||
private static PolylineOptions createPolylineOptions(PolylineOptions polylineOptions) {
|
||||
PolylineOptions polylineOptions2 = new PolylineOptions();
|
||||
polylineOptions2.color(polylineOptions.getColor());
|
||||
polylineOptions2.width(polylineOptions.getWidth());
|
||||
polylineOptions2.clickable(polylineOptions.isClickable());
|
||||
return polylineOptions2;
|
||||
}
|
||||
|
||||
private static PolygonOptions createPolygonOptions(PolygonOptions polygonOptions, boolean z, boolean z2) {
|
||||
float strokeWidth;
|
||||
PolygonOptions polygonOptions2 = new PolygonOptions();
|
||||
if (z) {
|
||||
polygonOptions2.fillColor(polygonOptions.getFillColor());
|
||||
}
|
||||
if (z2) {
|
||||
polygonOptions2.strokeColor(polygonOptions.getStrokeColor());
|
||||
strokeWidth = polygonOptions.getStrokeWidth();
|
||||
} else {
|
||||
strokeWidth = 0.0f;
|
||||
}
|
||||
polygonOptions2.strokeWidth(strokeWidth);
|
||||
polygonOptions2.clickable(polygonOptions.isClickable());
|
||||
return polygonOptions2;
|
||||
}
|
||||
|
||||
public MarkerOptions getMarkerOptions() {
|
||||
return createMarkerOptions(this.mMarkerOptions, isIconRandomColorMode(), this.mMarkerColor);
|
||||
}
|
||||
|
||||
public PolylineOptions getPolylineOptions() {
|
||||
return createPolylineOptions(this.mPolylineOptions);
|
||||
}
|
||||
|
||||
public PolygonOptions getPolygonOptions() {
|
||||
return createPolygonOptions(this.mPolygonOptions, this.mFill, this.mOutline);
|
||||
}
|
||||
|
||||
public static int computeRandomColor(int i) {
|
||||
Random random = new Random();
|
||||
int iRed = Color.red(i);
|
||||
int iGreen = Color.green(i);
|
||||
int iBlue = Color.blue(i);
|
||||
if (iRed != 0) {
|
||||
iRed = random.nextInt(iRed);
|
||||
}
|
||||
if (iBlue != 0) {
|
||||
iBlue = random.nextInt(iBlue);
|
||||
}
|
||||
if (iGreen != 0) {
|
||||
iGreen = random.nextInt(iGreen);
|
||||
}
|
||||
return Color.rgb(iRed, iGreen, iBlue);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("Style{\n balloon options=");
|
||||
sb.append(this.mBalloonOptions);
|
||||
sb.append(",\n fill=").append(this.mFill);
|
||||
sb.append(",\n outline=").append(this.mOutline);
|
||||
sb.append(",\n icon url=").append(this.mIconUrl);
|
||||
sb.append(",\n scale=").append(this.mScale);
|
||||
sb.append(",\n style id=").append(this.mStyleId);
|
||||
sb.append("\n}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
class KmlStyleParser {
|
||||
private static final String COLOR_STYLE_COLOR = "color";
|
||||
private static final String COLOR_STYLE_MODE = "colorMode";
|
||||
private static final String ICON_STYLE_HEADING = "heading";
|
||||
private static final String ICON_STYLE_HOTSPOT = "hotSpot";
|
||||
private static final String ICON_STYLE_SCALE = "scale";
|
||||
private static final String ICON_STYLE_URL = "Icon";
|
||||
private static final String LINE_STYLE_WIDTH = "width";
|
||||
private static final String POLY_STYLE_FILL = "fill";
|
||||
private static final String POLY_STYLE_OUTLINE = "outline";
|
||||
private static final String STYLE_MAP_KEY = "key";
|
||||
private static final String STYLE_MAP_NORMAL_STYLE = "normal";
|
||||
private static final String STYLE_TAG = "styleUrl";
|
||||
|
||||
KmlStyleParser() {
|
||||
}
|
||||
|
||||
static KmlStyle createStyle(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
KmlStyle kmlStyle = new KmlStyle();
|
||||
setStyleId(xmlPullParser.getAttributeValue(null, "id"), kmlStyle);
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("Style")) {
|
||||
return kmlStyle;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals("IconStyle")) {
|
||||
createIconStyle(xmlPullParser, kmlStyle);
|
||||
} else if (xmlPullParser.getName().equals("LineStyle")) {
|
||||
createLineStyle(xmlPullParser, kmlStyle);
|
||||
} else if (xmlPullParser.getName().equals("PolyStyle")) {
|
||||
createPolyStyle(xmlPullParser, kmlStyle);
|
||||
} else if (xmlPullParser.getName().equals("BalloonStyle")) {
|
||||
createBalloonStyle(xmlPullParser, kmlStyle);
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setStyleId(String str, KmlStyle kmlStyle) {
|
||||
if (str != null) {
|
||||
kmlStyle.setStyleId("#" + str);
|
||||
}
|
||||
}
|
||||
|
||||
private static void createIconStyle(XmlPullParser xmlPullParser, KmlStyle kmlStyle) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("IconStyle")) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals(ICON_STYLE_HEADING)) {
|
||||
kmlStyle.setHeading(Float.parseFloat(xmlPullParser.nextText()));
|
||||
} else if (xmlPullParser.getName().equals(ICON_STYLE_URL)) {
|
||||
setIconUrl(xmlPullParser, kmlStyle);
|
||||
} else if (xmlPullParser.getName().equals(ICON_STYLE_HOTSPOT)) {
|
||||
setIconHotSpot(xmlPullParser, kmlStyle);
|
||||
} else if (xmlPullParser.getName().equals(ICON_STYLE_SCALE)) {
|
||||
kmlStyle.setIconScale(Double.parseDouble(xmlPullParser.nextText()));
|
||||
} else if (xmlPullParser.getName().equals(COLOR_STYLE_COLOR)) {
|
||||
kmlStyle.setMarkerColor(xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals(COLOR_STYLE_MODE)) {
|
||||
kmlStyle.setIconColorMode(xmlPullParser.nextText());
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
static HashMap<String, String> createStyleMap(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String str = "#" + xmlPullParser.getAttributeValue(null, "id");
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
boolean z = false;
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("StyleMap")) {
|
||||
return map;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals(STYLE_MAP_KEY) && xmlPullParser.nextText().equals(STYLE_MAP_NORMAL_STYLE)) {
|
||||
z = true;
|
||||
} else if (xmlPullParser.getName().equals(STYLE_TAG) && z) {
|
||||
map.put(str, xmlPullParser.nextText());
|
||||
z = false;
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static void createBalloonStyle(XmlPullParser xmlPullParser, KmlStyle kmlStyle) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("BalloonStyle")) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 2 && xmlPullParser.getName().equals("text")) {
|
||||
kmlStyle.setInfoWindowText(xmlPullParser.nextText());
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setIconUrl(XmlPullParser xmlPullParser, KmlStyle kmlStyle) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals(ICON_STYLE_URL)) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 2 && xmlPullParser.getName().equals("href")) {
|
||||
kmlStyle.setIconUrl(xmlPullParser.nextText());
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setIconHotSpot(XmlPullParser xmlPullParser, KmlStyle kmlStyle) throws XmlPullParserException {
|
||||
if (xmlPullParser.isEmptyElementTag()) {
|
||||
return;
|
||||
}
|
||||
kmlStyle.setHotSpot(Float.parseFloat(xmlPullParser.getAttributeValue(null, "x")), Float.parseFloat(xmlPullParser.getAttributeValue(null, "y")), xmlPullParser.getAttributeValue(null, "xunits"), xmlPullParser.getAttributeValue(null, "yunits"));
|
||||
}
|
||||
|
||||
private static void createLineStyle(XmlPullParser xmlPullParser, KmlStyle kmlStyle) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("LineStyle")) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals(COLOR_STYLE_COLOR)) {
|
||||
kmlStyle.setOutlineColor(xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals(LINE_STYLE_WIDTH)) {
|
||||
kmlStyle.setWidth(Float.valueOf(xmlPullParser.nextText()));
|
||||
} else if (xmlPullParser.getName().equals(COLOR_STYLE_MODE)) {
|
||||
kmlStyle.setLineColorMode(xmlPullParser.nextText());
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
|
||||
private static void createPolyStyle(XmlPullParser xmlPullParser, KmlStyle kmlStyle) throws XmlPullParserException, IOException {
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
while (true) {
|
||||
if (eventType == 3 && xmlPullParser.getName().equals("PolyStyle")) {
|
||||
return;
|
||||
}
|
||||
if (eventType == 2) {
|
||||
if (xmlPullParser.getName().equals(COLOR_STYLE_COLOR)) {
|
||||
kmlStyle.setFillColor(xmlPullParser.nextText());
|
||||
} else if (xmlPullParser.getName().equals(POLY_STYLE_OUTLINE)) {
|
||||
kmlStyle.setOutline(KmlBoolean.parseBoolean(xmlPullParser.nextText()));
|
||||
} else if (xmlPullParser.getName().equals(POLY_STYLE_FILL)) {
|
||||
kmlStyle.setFill(KmlBoolean.parseBoolean(xmlPullParser.nextText()));
|
||||
} else if (xmlPullParser.getName().equals(COLOR_STYLE_MODE)) {
|
||||
kmlStyle.setPolyColorMode(xmlPullParser.nextText());
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlTrack extends KmlLineString {
|
||||
private final HashMap<String, String> mProperties;
|
||||
private final ArrayList<Long> mTimestamps;
|
||||
|
||||
public KmlTrack(ArrayList<LatLng> arrayList, ArrayList<Double> arrayList2, ArrayList<Long> arrayList3, HashMap<String, String> map) {
|
||||
super(arrayList, arrayList2);
|
||||
this.mTimestamps = arrayList3;
|
||||
this.mProperties = map;
|
||||
}
|
||||
|
||||
public ArrayList<Long> getTimestamps() {
|
||||
return this.mTimestamps;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getProperties() {
|
||||
return this.mProperties;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.google.maps.android.data.kml;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
public class KmlUtil {
|
||||
public static String substituteProperties(String str, KmlPlacemark kmlPlacemark) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
Matcher matcher = Pattern.compile("\\$\\[(.+?)]").matcher(str);
|
||||
while (matcher.find()) {
|
||||
String property = kmlPlacemark.getProperty(matcher.group(1));
|
||||
if (property != null) {
|
||||
matcher.appendReplacement(stringBuffer, property);
|
||||
}
|
||||
}
|
||||
matcher.appendTail(stringBuffer);
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user