Initial version -- added millennium read funcionality

This commit is contained in:
Pablo
2026-03-09 22:05:28 +01:00
commit 77c2ded482
2770 changed files with 141927 additions and 0 deletions
@@ -0,0 +1,66 @@
package com.google.maps.android.data.geojson;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/* JADX INFO: loaded from: classes2.dex */
public class BiMultiMap<K> extends HashMap<K, Object> {
private final Map<Object, K> mValuesToKeys = new HashMap();
@Override // java.util.HashMap, java.util.AbstractMap, java.util.Map
public void putAll(Map<? extends K, ?> map) {
for (Map.Entry<? extends K, ?> entry : map.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
@Override // java.util.HashMap, java.util.AbstractMap, java.util.Map
public Object put(K k, Object obj) {
if (obj instanceof Collection) {
return put((Object) k, (Collection) obj);
}
this.mValuesToKeys.put(obj, k);
return super.put(k, obj);
}
public Object put(K k, Collection collection) {
Iterator it = collection.iterator();
while (it.hasNext()) {
this.mValuesToKeys.put(it.next(), k);
}
return super.put((Object) k, collection);
}
@Override // java.util.HashMap, java.util.AbstractMap, java.util.Map
public Object remove(Object obj) {
Object objRemove = super.remove(obj);
if (objRemove instanceof Collection) {
Iterator it = ((Collection) objRemove).iterator();
while (it.hasNext()) {
this.mValuesToKeys.remove(it.next());
}
} else {
this.mValuesToKeys.remove(objRemove);
}
return objRemove;
}
@Override // java.util.HashMap, java.util.AbstractMap, java.util.Map
public void clear() {
super.clear();
this.mValuesToKeys.clear();
}
@Override // java.util.HashMap, java.util.AbstractMap
public BiMultiMap<K> clone() {
BiMultiMap<K> biMultiMap = new BiMultiMap<>();
biMultiMap.putAll((Map) super.clone());
return biMultiMap;
}
public K getKey(Object obj) {
return this.mValuesToKeys.get(obj);
}
}
@@ -0,0 +1,138 @@
package com.google.maps.android.data.geojson;
import com.google.android.gms.maps.model.LatLngBounds;
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.Arrays;
import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonFeature extends Feature implements Observer {
private final LatLngBounds mBoundingBox;
private GeoJsonLineStringStyle mLineStringStyle;
private GeoJsonPointStyle mPointStyle;
private GeoJsonPolygonStyle mPolygonStyle;
public GeoJsonFeature(Geometry geometry, String str, HashMap<String, String> map, LatLngBounds latLngBounds) {
super(geometry, str, map);
this.mId = str;
this.mBoundingBox = latLngBounds;
}
@Override // com.google.maps.android.data.Feature
public String setProperty(String str, String str2) {
return super.setProperty(str, str2);
}
@Override // com.google.maps.android.data.Feature
public String removeProperty(String str) {
return super.removeProperty(str);
}
public GeoJsonPointStyle getPointStyle() {
return this.mPointStyle;
}
public void setPointStyle(GeoJsonPointStyle geoJsonPointStyle) {
if (geoJsonPointStyle == null) {
throw new IllegalArgumentException("Point style cannot be null");
}
GeoJsonPointStyle geoJsonPointStyle2 = this.mPointStyle;
if (geoJsonPointStyle2 != null) {
geoJsonPointStyle2.deleteObserver(this);
}
this.mPointStyle = geoJsonPointStyle;
geoJsonPointStyle.addObserver(this);
checkRedrawFeature(this.mPointStyle);
}
public GeoJsonLineStringStyle getLineStringStyle() {
return this.mLineStringStyle;
}
public void setLineStringStyle(GeoJsonLineStringStyle geoJsonLineStringStyle) {
if (geoJsonLineStringStyle == null) {
throw new IllegalArgumentException("Line string style cannot be null");
}
GeoJsonLineStringStyle geoJsonLineStringStyle2 = this.mLineStringStyle;
if (geoJsonLineStringStyle2 != null) {
geoJsonLineStringStyle2.deleteObserver(this);
}
this.mLineStringStyle = geoJsonLineStringStyle;
geoJsonLineStringStyle.addObserver(this);
checkRedrawFeature(this.mLineStringStyle);
}
public GeoJsonPolygonStyle getPolygonStyle() {
return this.mPolygonStyle;
}
public void setPolygonStyle(GeoJsonPolygonStyle geoJsonPolygonStyle) {
if (geoJsonPolygonStyle == null) {
throw new IllegalArgumentException("Polygon style cannot be null");
}
GeoJsonPolygonStyle geoJsonPolygonStyle2 = this.mPolygonStyle;
if (geoJsonPolygonStyle2 != null) {
geoJsonPolygonStyle2.deleteObserver(this);
}
this.mPolygonStyle = geoJsonPolygonStyle;
geoJsonPolygonStyle.addObserver(this);
checkRedrawFeature(this.mPolygonStyle);
}
public PolygonOptions getPolygonOptions() {
return this.mPolygonStyle.toPolygonOptions();
}
public MarkerOptions getMarkerOptions() {
return this.mPointStyle.toMarkerOptions();
}
public PolylineOptions getPolylineOptions() {
return this.mLineStringStyle.toPolylineOptions();
}
private void checkRedrawFeature(GeoJsonStyle geoJsonStyle) {
if (hasGeometry() && Arrays.asList(geoJsonStyle.getGeometryType()).contains(getGeometry().getGeometryType())) {
setChanged();
notifyObservers();
}
}
@Override // com.google.maps.android.data.Feature
public void setGeometry(Geometry geometry) {
super.setGeometry(geometry);
setChanged();
notifyObservers();
}
public LatLngBounds getBoundingBox() {
return this.mBoundingBox;
}
public String toString() {
StringBuilder sb = new StringBuilder("Feature{\n bounding box=");
sb.append(this.mBoundingBox);
sb.append(",\n geometry=").append(getGeometry());
sb.append(",\n point style=").append(this.mPointStyle);
sb.append(",\n line string style=").append(this.mLineStringStyle);
sb.append(",\n polygon style=").append(this.mPolygonStyle);
sb.append(",\n id=").append(this.mId);
sb.append(",\n properties=").append(getProperties());
sb.append("\n}\n");
return sb.toString();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.Observer
public void update(Observable observable, Object obj) {
if (observable instanceof GeoJsonStyle) {
checkRedrawFeature((GeoJsonStyle) observable);
}
}
}
@@ -0,0 +1,21 @@
package com.google.maps.android.data.geojson;
import com.google.maps.android.data.Geometry;
import com.google.maps.android.data.MultiGeometry;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonGeometryCollection extends MultiGeometry {
public GeoJsonGeometryCollection(List<Geometry> list) {
super(list);
setGeometryType("GeometryCollection");
}
public String getType() {
return getGeometryType();
}
public List<Geometry> getGeometries() {
return getGeometryObject();
}
}
@@ -0,0 +1,100 @@
package com.google.maps.android.data.geojson;
import android.content.Context;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLngBounds;
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.Layer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonLayer extends Layer {
private LatLngBounds mBoundingBox;
public interface GeoJsonOnFeatureClickListener extends Layer.OnFeatureClickListener {
}
public GeoJsonLayer(GoogleMap googleMap, JSONObject jSONObject, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager) {
if (jSONObject == null) {
throw new IllegalArgumentException("GeoJSON file cannot be null");
}
this.mBoundingBox = null;
GeoJsonParser geoJsonParser = new GeoJsonParser(jSONObject);
this.mBoundingBox = geoJsonParser.getBoundingBox();
HashMap map = new HashMap();
Iterator<GeoJsonFeature> it = geoJsonParser.getFeatures().iterator();
while (it.hasNext()) {
map.put(it.next(), null);
}
storeRenderer(new GeoJsonRenderer(googleMap, map, markerManager, polygonManager, polylineManager, groundOverlayManager));
}
public GeoJsonLayer(GoogleMap googleMap, int i, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager) throws JSONException, IOException {
this(googleMap, createJsonFileObject(context.getResources().openRawResource(i)), markerManager, polygonManager, polylineManager, groundOverlayManager);
}
public GeoJsonLayer(GoogleMap googleMap, JSONObject jSONObject) {
this(googleMap, jSONObject, null, null, null, null);
}
public GeoJsonLayer(GoogleMap googleMap, int i, Context context) throws JSONException, IOException {
this(googleMap, createJsonFileObject(context.getResources().openRawResource(i)), null, null, null, null);
}
private static JSONObject createJsonFileObject(InputStream inputStream) throws JSONException, IOException {
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
while (true) {
String line = bufferedReader.readLine();
if (line != null) {
sb.append(line);
} else {
bufferedReader.close();
return new JSONObject(sb.toString());
}
}
}
@Override // com.google.maps.android.data.Layer
public void addLayerToMap() {
super.addGeoJsonToMap();
}
@Override // com.google.maps.android.data.Layer
public Iterable<GeoJsonFeature> getFeatures() {
return super.getFeatures();
}
public void addFeature(GeoJsonFeature geoJsonFeature) {
if (geoJsonFeature == null) {
throw new IllegalArgumentException("Feature cannot be null");
}
super.addFeature((Feature) geoJsonFeature);
}
public void removeFeature(GeoJsonFeature geoJsonFeature) {
if (geoJsonFeature == null) {
throw new IllegalArgumentException("Feature cannot be null");
}
super.removeFeature((Feature) geoJsonFeature);
}
public LatLngBounds getBoundingBox() {
return this.mBoundingBox;
}
public String toString() {
return "Collection{\n Bounding box=" + this.mBoundingBox + "\n}\n";
}
}
@@ -0,0 +1,31 @@
package com.google.maps.android.data.geojson;
import com.google.android.gms.maps.model.LatLng;
import com.google.maps.android.data.LineString;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonLineString extends LineString {
private final List<Double> mAltitudes;
public GeoJsonLineString(List<LatLng> list) {
this(list, null);
}
public GeoJsonLineString(List<LatLng> list, List<Double> list2) {
super(list);
this.mAltitudes = list2;
}
public String getType() {
return getGeometryType();
}
public List<LatLng> getCoordinates() {
return getGeometryObject();
}
public List<Double> getAltitudes() {
return this.mAltitudes;
}
}
@@ -0,0 +1,118 @@
package com.google.maps.android.data.geojson;
import com.google.android.gms.maps.model.PatternItem;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.maps.android.data.Style;
import java.util.Arrays;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonLineStringStyle extends Style implements GeoJsonStyle {
private static final String[] GEOMETRY_TYPE = {"LineString", "MultiLineString", "GeometryCollection"};
public GeoJsonLineStringStyle() {
this.mPolylineOptions = new PolylineOptions();
this.mPolylineOptions.clickable(true);
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public String[] getGeometryType() {
return GEOMETRY_TYPE;
}
public int getColor() {
return this.mPolylineOptions.getColor();
}
public void setColor(int i) {
this.mPolylineOptions.color(i);
styleChanged();
}
public boolean isClickable() {
return this.mPolylineOptions.isClickable();
}
public void setClickable(boolean z) {
this.mPolylineOptions.clickable(z);
styleChanged();
}
public boolean isGeodesic() {
return this.mPolylineOptions.isGeodesic();
}
public void setGeodesic(boolean z) {
this.mPolylineOptions.geodesic(z);
styleChanged();
}
public float getWidth() {
return this.mPolylineOptions.getWidth();
}
public void setWidth(float f) {
setLineStringWidth(f);
styleChanged();
}
public float getZIndex() {
return this.mPolylineOptions.getZIndex();
}
public void setZIndex(float f) {
this.mPolylineOptions.zIndex(f);
styleChanged();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public boolean isVisible() {
return this.mPolylineOptions.isVisible();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public void setVisible(boolean z) {
this.mPolylineOptions.visible(z);
styleChanged();
}
private void styleChanged() {
setChanged();
notifyObservers();
}
public PolylineOptions toPolylineOptions() {
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.color(this.mPolylineOptions.getColor());
polylineOptions.clickable(this.mPolylineOptions.isClickable());
polylineOptions.geodesic(this.mPolylineOptions.isGeodesic());
polylineOptions.visible(this.mPolylineOptions.isVisible());
polylineOptions.width(this.mPolylineOptions.getWidth());
polylineOptions.zIndex(this.mPolylineOptions.getZIndex());
polylineOptions.pattern(getPattern());
return polylineOptions;
}
public String toString() {
StringBuilder sb = new StringBuilder("LineStringStyle{\n geometry type=");
sb.append(Arrays.toString(GEOMETRY_TYPE));
sb.append(",\n color=").append(getColor());
sb.append(",\n clickable=").append(isClickable());
sb.append(",\n geodesic=").append(isGeodesic());
sb.append(",\n visible=").append(isVisible());
sb.append(",\n width=").append(getWidth());
sb.append(",\n z index=").append(getZIndex());
sb.append(",\n pattern=").append(getPattern());
sb.append("\n}\n");
return sb.toString();
}
public List<PatternItem> getPattern() {
return this.mPolylineOptions.getPattern();
}
public void setPattern(List<PatternItem> list) {
this.mPolylineOptions.pattern(list);
styleChanged();
}
}
@@ -0,0 +1,29 @@
package com.google.maps.android.data.geojson;
import com.google.maps.android.data.Geometry;
import com.google.maps.android.data.MultiGeometry;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonMultiLineString extends MultiGeometry {
public GeoJsonMultiLineString(List<GeoJsonLineString> list) {
super(list);
setGeometryType("MultiLineString");
}
public String getType() {
return getGeometryType();
}
public List<GeoJsonLineString> getLineStrings() {
List geometryObject = getGeometryObject();
ArrayList arrayList = new ArrayList();
Iterator it = geometryObject.iterator();
while (it.hasNext()) {
arrayList.add((GeoJsonLineString) ((Geometry) it.next()));
}
return arrayList;
}
}
@@ -0,0 +1,29 @@
package com.google.maps.android.data.geojson;
import com.google.maps.android.data.Geometry;
import com.google.maps.android.data.MultiGeometry;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonMultiPoint extends MultiGeometry {
public GeoJsonMultiPoint(List<GeoJsonPoint> list) {
super(list);
setGeometryType("MultiPoint");
}
public String getType() {
return getGeometryType();
}
public List<GeoJsonPoint> getPoints() {
List geometryObject = getGeometryObject();
ArrayList arrayList = new ArrayList();
Iterator it = geometryObject.iterator();
while (it.hasNext()) {
arrayList.add((GeoJsonPoint) ((Geometry) it.next()));
}
return arrayList;
}
}
@@ -0,0 +1,29 @@
package com.google.maps.android.data.geojson;
import com.google.maps.android.data.Geometry;
import com.google.maps.android.data.MultiGeometry;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonMultiPolygon extends MultiGeometry {
public GeoJsonMultiPolygon(List<GeoJsonPolygon> list) {
super(list);
setGeometryType("MultiPolygon");
}
public String getType() {
return getGeometryType();
}
public List<GeoJsonPolygon> getPolygons() {
List geometryObject = getGeometryObject();
ArrayList arrayList = new ArrayList();
Iterator it = geometryObject.iterator();
while (it.hasNext()) {
arrayList.add((GeoJsonPolygon) ((Geometry) it.next()));
}
return arrayList;
}
}
@@ -0,0 +1,277 @@
package com.google.maps.android.data.geojson;
import android.util.Log;
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.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonParser {
private static final String BOUNDING_BOX = "bbox";
private static final String FEATURE = "Feature";
private static final String FEATURE_COLLECTION = "FeatureCollection";
private static final String FEATURE_COLLECTION_ARRAY = "features";
private static final String FEATURE_GEOMETRY = "geometry";
private static final String FEATURE_ID = "id";
private static final String GEOMETRY_COLLECTION = "GeometryCollection";
private static final String GEOMETRY_COLLECTION_ARRAY = "geometries";
private static final String GEOMETRY_COORDINATES_ARRAY = "coordinates";
private static final String LINESTRING = "LineString";
private static final String LOG_TAG = "GeoJsonParser";
private static final String MULTILINESTRING = "MultiLineString";
private static final String MULTIPOINT = "MultiPoint";
private static final String MULTIPOLYGON = "MultiPolygon";
private static final String POINT = "Point";
private static final String POLYGON = "Polygon";
private static final String PROPERTIES = "properties";
private final JSONObject mGeoJsonFile;
private final ArrayList<GeoJsonFeature> mGeoJsonFeatures = new ArrayList<>();
private LatLngBounds mBoundingBox = null;
private static class LatLngAlt {
public final Double altitude;
public final LatLng latLng;
LatLngAlt(LatLng latLng, Double d) {
this.latLng = latLng;
this.altitude = d;
}
}
public GeoJsonParser(JSONObject jSONObject) {
this.mGeoJsonFile = jSONObject;
parseGeoJson();
}
private static boolean isGeometry(String str) {
return str.matches("Point|MultiPoint|LineString|MultiLineString|Polygon|MultiPolygon|GeometryCollection");
}
private static GeoJsonFeature parseFeature(JSONObject jSONObject) {
HashMap<String, String> map = new HashMap<>();
try {
String string = jSONObject.has(FEATURE_ID) ? jSONObject.getString(FEATURE_ID) : null;
LatLngBounds boundingBox = jSONObject.has(BOUNDING_BOX) ? parseBoundingBox(jSONObject.getJSONArray(BOUNDING_BOX)) : null;
Geometry geometry = (!jSONObject.has(FEATURE_GEOMETRY) || jSONObject.isNull(FEATURE_GEOMETRY)) ? null : parseGeometry(jSONObject.getJSONObject(FEATURE_GEOMETRY));
if (jSONObject.has(PROPERTIES) && !jSONObject.isNull(PROPERTIES)) {
map = parseProperties(jSONObject.getJSONObject(PROPERTIES));
}
return new GeoJsonFeature(geometry, string, map, boundingBox);
} catch (JSONException unused) {
Log.w(LOG_TAG, "Feature could not be successfully parsed " + jSONObject.toString());
return null;
}
}
private static LatLngBounds parseBoundingBox(JSONArray jSONArray) throws JSONException {
return new LatLngBounds(new LatLng(jSONArray.getDouble(1), jSONArray.getDouble(0)), new LatLng(jSONArray.getDouble(3), jSONArray.getDouble(2)));
}
public static Geometry parseGeometry(JSONObject jSONObject) {
String string;
JSONArray jSONArray;
try {
string = jSONObject.getString("type");
} catch (JSONException unused) {
}
if (string.equals(GEOMETRY_COLLECTION)) {
jSONArray = jSONObject.getJSONArray(GEOMETRY_COLLECTION_ARRAY);
} else {
if (isGeometry(string)) {
jSONArray = jSONObject.getJSONArray(GEOMETRY_COORDINATES_ARRAY);
}
return null;
}
return createGeometry(string, jSONArray);
}
private static GeoJsonFeature parseGeometryToFeature(JSONObject jSONObject) {
Geometry geometry = parseGeometry(jSONObject);
if (geometry != null) {
return new GeoJsonFeature(geometry, null, new HashMap(), null);
}
Log.w(LOG_TAG, "Geometry could not be parsed");
return null;
}
private static HashMap<String, String> parseProperties(JSONObject jSONObject) throws JSONException {
HashMap<String, String> map = new HashMap<>();
Iterator<String> itKeys = jSONObject.keys();
while (itKeys.hasNext()) {
String next = itKeys.next();
map.put(next, jSONObject.isNull(next) ? null : jSONObject.getString(next));
}
return map;
}
private static Geometry createGeometry(String str, JSONArray jSONArray) throws JSONException {
str.hashCode();
switch (str) {
case "MultiPolygon":
return createMultiPolygon(jSONArray);
case "MultiPoint":
return createMultiPoint(jSONArray);
case "MultiLineString":
return createMultiLineString(jSONArray);
case "Point":
return createPoint(jSONArray);
case "Polygon":
return createPolygon(jSONArray);
case "LineString":
return createLineString(jSONArray);
case "GeometryCollection":
return createGeometryCollection(jSONArray);
default:
return null;
}
}
private static GeoJsonPoint createPoint(JSONArray jSONArray) throws JSONException {
LatLngAlt coordinate = parseCoordinate(jSONArray);
return new GeoJsonPoint(coordinate.latLng, coordinate.altitude);
}
private static GeoJsonMultiPoint createMultiPoint(JSONArray jSONArray) throws JSONException {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
arrayList.add(createPoint(jSONArray.getJSONArray(i)));
}
return new GeoJsonMultiPoint(arrayList);
}
private static GeoJsonLineString createLineString(JSONArray jSONArray) throws JSONException {
ArrayList<LatLngAlt> coordinatesArray = parseCoordinatesArray(jSONArray);
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
for (LatLngAlt latLngAlt : coordinatesArray) {
arrayList.add(latLngAlt.latLng);
if (latLngAlt.altitude != null) {
arrayList2.add(latLngAlt.altitude);
}
}
return new GeoJsonLineString(arrayList, arrayList2);
}
private static GeoJsonMultiLineString createMultiLineString(JSONArray jSONArray) throws JSONException {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
arrayList.add(createLineString(jSONArray.getJSONArray(i)));
}
return new GeoJsonMultiLineString(arrayList);
}
private static GeoJsonPolygon createPolygon(JSONArray jSONArray) throws JSONException {
return new GeoJsonPolygon(parseCoordinatesArrays(jSONArray));
}
private static GeoJsonMultiPolygon createMultiPolygon(JSONArray jSONArray) throws JSONException {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
arrayList.add(createPolygon(jSONArray.getJSONArray(i)));
}
return new GeoJsonMultiPolygon(arrayList);
}
private static GeoJsonGeometryCollection createGeometryCollection(JSONArray jSONArray) throws JSONException {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
Geometry geometry = parseGeometry(jSONArray.getJSONObject(i));
if (geometry != null) {
arrayList.add(geometry);
}
}
return new GeoJsonGeometryCollection(arrayList);
}
private static LatLngAlt parseCoordinate(JSONArray jSONArray) throws JSONException {
return new LatLngAlt(new LatLng(jSONArray.getDouble(1), jSONArray.getDouble(0)), jSONArray.length() < 3 ? null : Double.valueOf(jSONArray.getDouble(2)));
}
private static ArrayList<LatLngAlt> parseCoordinatesArray(JSONArray jSONArray) throws JSONException {
ArrayList<LatLngAlt> arrayList = new ArrayList<>();
for (int i = 0; i < jSONArray.length(); i++) {
arrayList.add(parseCoordinate(jSONArray.getJSONArray(i)));
}
return arrayList;
}
private static ArrayList<ArrayList<LatLng>> parseCoordinatesArrays(JSONArray jSONArray) throws JSONException {
ArrayList<ArrayList<LatLng>> arrayList = new ArrayList<>();
for (int i = 0; i < jSONArray.length(); i++) {
ArrayList<LatLngAlt> coordinatesArray = parseCoordinatesArray(jSONArray.getJSONArray(i));
ArrayList<LatLng> arrayList2 = new ArrayList<>();
Iterator<LatLngAlt> it = coordinatesArray.iterator();
while (it.hasNext()) {
arrayList2.add(it.next().latLng);
}
arrayList.add(arrayList2);
}
return arrayList;
}
private void parseGeoJson() {
try {
String string = this.mGeoJsonFile.getString("type");
if (string.equals(FEATURE)) {
GeoJsonFeature feature = parseFeature(this.mGeoJsonFile);
if (feature != null) {
this.mGeoJsonFeatures.add(feature);
}
} else if (string.equals(FEATURE_COLLECTION)) {
this.mGeoJsonFeatures.addAll(parseFeatureCollection(this.mGeoJsonFile));
} else if (isGeometry(string)) {
GeoJsonFeature geometryToFeature = parseGeometryToFeature(this.mGeoJsonFile);
if (geometryToFeature != null) {
this.mGeoJsonFeatures.add(geometryToFeature);
}
} else {
Log.w(LOG_TAG, "GeoJSON file could not be parsed.");
}
} catch (JSONException unused) {
Log.w(LOG_TAG, "GeoJSON file could not be parsed.");
}
}
private ArrayList<GeoJsonFeature> parseFeatureCollection(JSONObject jSONObject) {
ArrayList<GeoJsonFeature> arrayList = new ArrayList<>();
try {
JSONArray jSONArray = jSONObject.getJSONArray(FEATURE_COLLECTION_ARRAY);
if (jSONObject.has(BOUNDING_BOX)) {
this.mBoundingBox = parseBoundingBox(jSONObject.getJSONArray(BOUNDING_BOX));
}
for (int i = 0; i < jSONArray.length(); i++) {
try {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
if (jSONObject2.getString("type").equals(FEATURE)) {
GeoJsonFeature feature = parseFeature(jSONObject2);
if (feature == null) {
Log.w(LOG_TAG, "Index of Feature in Feature Collection that could not be created: " + i);
} else {
arrayList.add(feature);
}
}
} catch (JSONException unused) {
Log.w(LOG_TAG, "Index of Feature in Feature Collection that could not be created: " + i);
}
}
return arrayList;
} catch (JSONException unused2) {
Log.w(LOG_TAG, "Feature Collection could not be created.");
return arrayList;
}
}
public ArrayList<GeoJsonFeature> getFeatures() {
return this.mGeoJsonFeatures;
}
public LatLngBounds getBoundingBox() {
return this.mBoundingBox;
}
}
@@ -0,0 +1,30 @@
package com.google.maps.android.data.geojson;
import com.google.android.gms.maps.model.LatLng;
import com.google.maps.android.data.Point;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonPoint extends Point {
private final Double mAltitude;
public GeoJsonPoint(LatLng latLng) {
this(latLng, null);
}
public GeoJsonPoint(LatLng latLng, Double d) {
super(latLng);
this.mAltitude = d;
}
public String getType() {
return getGeometryType();
}
public LatLng getCoordinates() {
return getGeometryObject();
}
public Double getAltitude() {
return this.mAltitude;
}
}
@@ -0,0 +1,170 @@
package com.google.maps.android.data.geojson;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.maps.android.data.Style;
import java.util.Arrays;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonPointStyle extends Style implements GeoJsonStyle {
private static final String[] GEOMETRY_TYPE = {"Point", "MultiPoint", "GeometryCollection"};
public GeoJsonPointStyle() {
this.mMarkerOptions = new MarkerOptions();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public String[] getGeometryType() {
return GEOMETRY_TYPE;
}
public float getAlpha() {
return this.mMarkerOptions.getAlpha();
}
public void setAlpha(float f) {
this.mMarkerOptions.alpha(f);
styleChanged();
}
public float getAnchorU() {
return this.mMarkerOptions.getAnchorU();
}
public float getAnchorV() {
return this.mMarkerOptions.getAnchorV();
}
public void setAnchor(float f, float f2) {
setMarkerHotSpot(f, f2, "fraction", "fraction");
styleChanged();
}
public boolean isDraggable() {
return this.mMarkerOptions.isDraggable();
}
public void setDraggable(boolean z) {
this.mMarkerOptions.draggable(z);
styleChanged();
}
public boolean isFlat() {
return this.mMarkerOptions.isFlat();
}
public void setFlat(boolean z) {
this.mMarkerOptions.flat(z);
styleChanged();
}
public BitmapDescriptor getIcon() {
return this.mMarkerOptions.getIcon();
}
public void setIcon(BitmapDescriptor bitmapDescriptor) {
this.mMarkerOptions.icon(bitmapDescriptor);
styleChanged();
}
public float getInfoWindowAnchorU() {
return this.mMarkerOptions.getInfoWindowAnchorU();
}
public float getInfoWindowAnchorV() {
return this.mMarkerOptions.getInfoWindowAnchorV();
}
public void setInfoWindowAnchor(float f, float f2) {
this.mMarkerOptions.infoWindowAnchor(f, f2);
styleChanged();
}
@Override // com.google.maps.android.data.Style
public float getRotation() {
return this.mMarkerOptions.getRotation();
}
public void setRotation(float f) {
setMarkerRotation(f);
styleChanged();
}
public String getSnippet() {
return this.mMarkerOptions.getSnippet();
}
public void setSnippet(String str) {
this.mMarkerOptions.snippet(str);
styleChanged();
}
public String getTitle() {
return this.mMarkerOptions.getTitle();
}
public void setTitle(String str) {
this.mMarkerOptions.title(str);
styleChanged();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public boolean isVisible() {
return this.mMarkerOptions.isVisible();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public void setVisible(boolean z) {
this.mMarkerOptions.visible(z);
styleChanged();
}
private void styleChanged() {
setChanged();
notifyObservers();
}
public MarkerOptions toMarkerOptions() {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.alpha(this.mMarkerOptions.getAlpha());
markerOptions.anchor(this.mMarkerOptions.getAnchorU(), this.mMarkerOptions.getAnchorV());
markerOptions.draggable(this.mMarkerOptions.isDraggable());
markerOptions.flat(this.mMarkerOptions.isFlat());
markerOptions.icon(this.mMarkerOptions.getIcon());
markerOptions.infoWindowAnchor(this.mMarkerOptions.getInfoWindowAnchorU(), this.mMarkerOptions.getInfoWindowAnchorV());
markerOptions.rotation(this.mMarkerOptions.getRotation());
markerOptions.snippet(this.mMarkerOptions.getSnippet());
markerOptions.title(this.mMarkerOptions.getTitle());
markerOptions.visible(this.mMarkerOptions.isVisible());
markerOptions.zIndex(this.mMarkerOptions.getZIndex());
return markerOptions;
}
public String toString() {
StringBuilder sb = new StringBuilder("PointStyle{\n geometry type=");
sb.append(Arrays.toString(GEOMETRY_TYPE));
sb.append(",\n alpha=").append(getAlpha());
sb.append(",\n anchor U=").append(getAnchorU());
sb.append(",\n anchor V=").append(getAnchorV());
sb.append(",\n draggable=").append(isDraggable());
sb.append(",\n flat=").append(isFlat());
sb.append(",\n info window anchor U=").append(getInfoWindowAnchorU());
sb.append(",\n info window anchor V=").append(getInfoWindowAnchorV());
sb.append(",\n rotation=").append(getRotation());
sb.append(",\n snippet=").append(getSnippet());
sb.append(",\n title=").append(getTitle());
sb.append(",\n visible=").append(isVisible());
sb.append(",\n z index=").append(getZIndex());
sb.append("\n}\n");
return sb.toString();
}
public float getZIndex() {
return this.mMarkerOptions.getZIndex();
}
public void setZIndex(float f) {
this.mMarkerOptions.zIndex(f);
styleChanged();
}
}
@@ -0,0 +1,57 @@
package com.google.maps.android.data.geojson;
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 GeoJsonPolygon implements DataPolygon {
private static final String GEOMETRY_TYPE = "Polygon";
private static final int POLYGON_INNER_COORDINATE_INDEX = 1;
private static final int POLYGON_OUTER_COORDINATE_INDEX = 0;
private final List<? extends List<LatLng>> mCoordinates;
public GeoJsonPolygon(List<? extends List<LatLng>> list) {
if (list == null) {
throw new IllegalArgumentException("Coordinates cannot be null");
}
this.mCoordinates = list;
}
public String getType() {
return "Polygon";
}
public List<? extends List<LatLng>> getCoordinates() {
return this.mCoordinates;
}
@Override // com.google.maps.android.data.Geometry
public List<? extends List<LatLng>> getGeometryObject() {
return getCoordinates();
}
@Override // com.google.maps.android.data.Geometry
public String getGeometryType() {
return getType();
}
@Override // com.google.maps.android.data.DataPolygon
public ArrayList<LatLng> getOuterBoundaryCoordinates() {
return (ArrayList) getCoordinates().get(0);
}
@Override // com.google.maps.android.data.DataPolygon
public ArrayList<ArrayList<LatLng>> getInnerBoundaryCoordinates() {
ArrayList<ArrayList<LatLng>> arrayList = new ArrayList<>();
for (int i = 1; i < getCoordinates().size(); i++) {
arrayList.add((ArrayList) getCoordinates().get(i));
}
return arrayList;
}
public String toString() {
return "Polygon{\n coordinates=" + this.mCoordinates + "\n}\n";
}
}
@@ -0,0 +1,141 @@
package com.google.maps.android.data.geojson;
import com.google.android.gms.maps.model.PatternItem;
import com.google.android.gms.maps.model.PolygonOptions;
import com.google.maps.android.data.Style;
import com.google.maps.android.data.kml.KmlPolygon;
import java.util.Arrays;
import java.util.List;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonPolygonStyle extends Style implements GeoJsonStyle {
private static final String[] GEOMETRY_TYPE = {KmlPolygon.GEOMETRY_TYPE, "MultiPolygon", "GeometryCollection"};
public GeoJsonPolygonStyle() {
this.mPolygonOptions = new PolygonOptions();
this.mPolygonOptions.clickable(true);
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public String[] getGeometryType() {
return GEOMETRY_TYPE;
}
public int getFillColor() {
return this.mPolygonOptions.getFillColor();
}
public void setFillColor(int i) {
setPolygonFillColor(i);
styleChanged();
}
public boolean isGeodesic() {
return this.mPolygonOptions.isGeodesic();
}
public void setGeodesic(boolean z) {
this.mPolygonOptions.geodesic(z);
styleChanged();
}
public int getStrokeColor() {
return this.mPolygonOptions.getStrokeColor();
}
public void setStrokeColor(int i) {
this.mPolygonOptions.strokeColor(i);
styleChanged();
}
public int getStrokeJointType() {
return this.mPolygonOptions.getStrokeJointType();
}
public void setStrokeJointType(int i) {
this.mPolygonOptions.strokeJointType(i);
styleChanged();
}
public List<PatternItem> getStrokePattern() {
return this.mPolygonOptions.getStrokePattern();
}
public void setStrokePattern(List<PatternItem> list) {
this.mPolygonOptions.strokePattern(list);
styleChanged();
}
public float getStrokeWidth() {
return this.mPolygonOptions.getStrokeWidth();
}
public void setStrokeWidth(float f) {
setPolygonStrokeWidth(f);
styleChanged();
}
public float getZIndex() {
return this.mPolygonOptions.getZIndex();
}
public void setZIndex(float f) {
this.mPolygonOptions.zIndex(f);
styleChanged();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public boolean isVisible() {
return this.mPolygonOptions.isVisible();
}
@Override // com.google.maps.android.data.geojson.GeoJsonStyle
public void setVisible(boolean z) {
this.mPolygonOptions.visible(z);
styleChanged();
}
private void styleChanged() {
setChanged();
notifyObservers();
}
public PolygonOptions toPolygonOptions() {
PolygonOptions polygonOptions = new PolygonOptions();
polygonOptions.fillColor(this.mPolygonOptions.getFillColor());
polygonOptions.geodesic(this.mPolygonOptions.isGeodesic());
polygonOptions.strokeColor(this.mPolygonOptions.getStrokeColor());
polygonOptions.strokeJointType(this.mPolygonOptions.getStrokeJointType());
polygonOptions.strokePattern(this.mPolygonOptions.getStrokePattern());
polygonOptions.strokeWidth(this.mPolygonOptions.getStrokeWidth());
polygonOptions.visible(this.mPolygonOptions.isVisible());
polygonOptions.zIndex(this.mPolygonOptions.getZIndex());
polygonOptions.clickable(this.mPolygonOptions.isClickable());
return polygonOptions;
}
public String toString() {
StringBuilder sb = new StringBuilder("PolygonStyle{\n geometry type=");
sb.append(Arrays.toString(GEOMETRY_TYPE));
sb.append(",\n fill color=").append(getFillColor());
sb.append(",\n geodesic=").append(isGeodesic());
sb.append(",\n stroke color=").append(getStrokeColor());
sb.append(",\n stroke joint type=").append(getStrokeJointType());
sb.append(",\n stroke pattern=").append(getStrokePattern());
sb.append(",\n stroke width=").append(getStrokeWidth());
sb.append(",\n visible=").append(isVisible());
sb.append(",\n z index=").append(getZIndex());
sb.append(",\n clickable=").append(isClickable());
sb.append("\n}\n");
return sb.toString();
}
public void setClickable(boolean z) {
this.mPolygonOptions.clickable(z);
styleChanged();
}
public boolean isClickable() {
return this.mPolygonOptions.isClickable();
}
}
@@ -0,0 +1,102 @@
package com.google.maps.android.data.geojson;
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.Feature;
import com.google.maps.android.data.Renderer;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
/* JADX INFO: loaded from: classes2.dex */
public class GeoJsonRenderer extends Renderer implements Observer {
private static final Object FEATURE_NOT_ON_MAP = null;
GeoJsonRenderer(GoogleMap googleMap, HashMap<GeoJsonFeature, Object> map, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager) {
super(googleMap, map, markerManager, polygonManager, polylineManager, groundOverlayManager);
}
@Override // com.google.maps.android.data.Renderer
public void setMap(GoogleMap googleMap) {
super.setMap(googleMap);
Iterator<Feature> it = super.getFeatures().iterator();
while (it.hasNext()) {
redrawFeatureToMap((GeoJsonFeature) it.next(), googleMap);
}
}
public void addLayerToMap() {
if (isLayerOnMap()) {
return;
}
setLayerVisibility(true);
Iterator<Feature> it = super.getFeatures().iterator();
while (it.hasNext()) {
addFeature((GeoJsonFeature) it.next());
}
}
public void addFeature(GeoJsonFeature geoJsonFeature) {
super.addFeature((Feature) geoJsonFeature);
if (isLayerOnMap()) {
geoJsonFeature.addObserver(this);
}
}
public void removeLayerFromMap() {
if (isLayerOnMap()) {
for (Feature feature : super.getFeatures()) {
removeFromMap(super.getAllFeatures().get(feature));
feature.deleteObserver(this);
}
setLayerVisibility(false);
}
}
public void removeFeature(GeoJsonFeature geoJsonFeature) {
super.removeFeature((Feature) geoJsonFeature);
if (super.getFeatures().contains(geoJsonFeature)) {
geoJsonFeature.deleteObserver(this);
}
}
private void redrawFeatureToMap(GeoJsonFeature geoJsonFeature) {
redrawFeatureToMap(geoJsonFeature, getMap());
}
private void redrawFeatureToMap(GeoJsonFeature geoJsonFeature, GoogleMap googleMap) {
removeFromMap(getAllFeatures().get(geoJsonFeature));
putFeatures(geoJsonFeature, FEATURE_NOT_ON_MAP);
if (googleMap == null || !geoJsonFeature.hasGeometry()) {
return;
}
putFeatures(geoJsonFeature, addGeoJsonFeatureToMap(geoJsonFeature, geoJsonFeature.getGeometry()));
}
@Override // java.util.Observer
public void update(Observable observable, Object obj) {
if (observable instanceof GeoJsonFeature) {
GeoJsonFeature geoJsonFeature = (GeoJsonFeature) observable;
Object obj2 = getAllFeatures().get(geoJsonFeature);
Object obj3 = FEATURE_NOT_ON_MAP;
boolean z = obj2 != obj3;
if (z && geoJsonFeature.hasGeometry()) {
redrawFeatureToMap(geoJsonFeature);
return;
}
if (z && !geoJsonFeature.hasGeometry()) {
removeFromMap(getAllFeatures().get(geoJsonFeature));
putFeatures(geoJsonFeature, obj3);
} else {
if (z || !geoJsonFeature.hasGeometry()) {
return;
}
addFeature(geoJsonFeature);
}
}
}
}
@@ -0,0 +1,10 @@
package com.google.maps.android.data.geojson;
/* JADX INFO: loaded from: classes2.dex */
interface GeoJsonStyle {
String[] getGeometryType();
boolean isVisible();
void setVisible(boolean z);
}