/** * Checks whether the new style that was set requires the feature to be redrawn. If the * geometry and the style that was set match, then the feature is redrawn. * * @param style style to check if a redraw is needed */ private void checkRedrawFeature(GeoJsonStyle style) { if (hasGeometry() && Arrays.asList(style.getGeometryType()) .contains(getGeometry().getGeometryType())) { // Don't redraw objects that aren't on the map setChanged(); notifyObservers(); } }
public void testMultiGeometries() throws Exception { XmlPullParser xmlPullParser = createParser(R.raw.amu_nested_multigeometry); KmlPlacemark feature = KmlFeatureParser.createPlacemark(xmlPullParser); assertEquals(feature.getProperty("name"), "multiPointLine"); assertEquals(feature.getProperty("description"), "Nested MultiGeometry structure"); assertEquals(feature.getGeometry().getGeometryType(), "MultiGeometry"); ArrayList<Geometry> objects = (ArrayList<Geometry>) feature.getGeometry().getGeometryObject(); assertEquals(objects.get(0).getGeometryType(), "Point"); assertEquals(objects.get(1).getGeometryType(), "LineString"); assertEquals(objects.get(2).getGeometryType(), "MultiGeometry"); ArrayList<Geometry> subObjects = (ArrayList<Geometry>) objects.get(2).getGeometryObject(); assertEquals(subObjects.get(0).getGeometryType(), "Point"); assertEquals(subObjects.get(1).getGeometryType(), "LineString"); }
/** * Adds the marker icon stored in mMarkerIconCache, to the {@link com.google.android.gms.maps.model.Marker} * * @param iconUrl icon url of icon to add to markers * @param placemarks */ private void addIconToMarkers(String iconUrl, HashMap<KmlPlacemark, Object> placemarks) { for (Feature placemark : placemarks.keySet()) { KmlStyle urlStyle = getStylesRenderer().get(placemark.getId()); KmlStyle inlineStyle = ((KmlPlacemark) placemark).getInlineStyle(); if ("Point".equals(placemark.getGeometry().getGeometryType())) { boolean isInlineStyleIcon = inlineStyle != null && iconUrl .equals(inlineStyle.getIconUrl()); boolean isPlacemarkStyleIcon = urlStyle != null && iconUrl .equals(urlStyle.getIconUrl()); if (isInlineStyleIcon) { scaleBitmap(inlineStyle, placemarks, (KmlPlacemark) placemark); } else if (isPlacemarkStyleIcon) { scaleBitmap(urlStyle, placemarks, (KmlPlacemark) placemark); } } } }
public void testPolygon() throws Exception { XmlPullParser xmlPullParser = createParser(R.raw.amu_basic_placemark); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertNotNull(placemark); assertEquals(placemark.getGeometry().getGeometryType(), "Polygon"); KmlPolygon polygon = ((KmlPolygon) placemark.getGeometry()); assertEquals(polygon.getInnerBoundaryCoordinates().size(), 2); assertEquals(polygon.getOuterBoundaryCoordinates().size(), 5); }
public void testMultiGeometry() throws Exception { XmlPullParser xmlPullParser = createParser(R.raw.amu_multigeometry_placemarks); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertNotNull( placemark ); assertEquals( placemark .getGeometry().getGeometryType(), "MultiGeometry"); KmlMultiGeometry multiGeometry = ((KmlMultiGeometry) placemark .getGeometry()); assertEquals(multiGeometry.getGeometryObject().size(), 3); }
public void testParseGeometryCollection() throws Exception { GeoJsonParser parser = new GeoJsonParser(validGeometryCollection()); assertEquals(1, parser.getFeatures().size()); for (GeoJsonFeature feature : parser.getFeatures()) { assertEquals("GeometryCollection", feature.getGeometry().getGeometryType()); int size = 0; for (String property : feature.getPropertyKeys()) { size++; } assertEquals(2, size); assertEquals("Popsicles", feature.getId()); GeoJsonGeometryCollection geometry = ((GeoJsonGeometryCollection) feature .getGeometry()); assertEquals(1, geometry.getGeometries().size()); for (Geometry geoJsonGeometry : geometry.getGeometries()) { assertEquals("GeometryCollection", geoJsonGeometry.getGeometryType()); } } }
assertNull(parser.getBoundingBox()); assertEquals(2, parser.getFeatures().size()); assertTrue(!parser.getFeatures().get(0).getGeometry().getGeometryType().equals("Polygon") && !parser .getFeatures().get(1).getGeometry().getGeometryType().equals("Polygon"));
public void testInlineStyle() throws Exception { XmlPullParser parser = createParser(com.google.maps.android.test.R.raw.amu_inline_style); KmlParser mParser = new KmlParser(parser); mParser.parseKml(); assertNotNull(mParser.getPlacemarks()); assertEquals(mParser.getPlacemarks().size(), 1); for (KmlPlacemark placemark : mParser.getPlacemarks().keySet()) { KmlStyle inlineStyle = placemark.getInlineStyle(); assertNotNull(inlineStyle); assertEquals(inlineStyle.getPolylineOptions().getColor(), Color.parseColor("#000000")); assertEquals(inlineStyle.getPolygonOptions().getFillColor(), Color.parseColor("#ffffff")); assertEquals(inlineStyle.getPolylineOptions().getColor(), inlineStyle.getPolygonOptions().getStrokeColor()); assertEquals(placemark.getGeometry().getGeometryType(), "MultiGeometry"); } }
String geometryType = geometry.getGeometryType(); switch (geometryType) { case "Point":
String geometryType = geometry.getGeometryType(); boolean hasDrawOrder = placemark.hasProperty("drawOrder"); float drawOrder = 0;