當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiPolygon.getNumGeometries方法代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.MultiPolygon.getNumGeometries方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiPolygon.getNumGeometries方法的具體用法?Java MultiPolygon.getNumGeometries怎麽用?Java MultiPolygon.getNumGeometries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vividsolutions.jts.geom.MultiPolygon的用法示例。


在下文中一共展示了MultiPolygon.getNumGeometries方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: repair

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/**
 *
 * @param geom
 * @return
 */
public static Geometry repair (Geometry geom) {
    GeometryFactory factory = geom.getFactory();
    if (geom instanceof MultiPolygon) {
        MultiPolygon mp = (MultiPolygon)geom;
        Polygon[] polys = new Polygon[mp.getNumGeometries()];
        for (int i = 0; i < mp.getNumGeometries(); i += 1) {
            polys[i] = repair((Polygon)mp.getGeometryN(i));
        }
        return factory.createMultiPolygon(polys);
    } else if (geom instanceof Polygon) {
        return repair((Polygon)geom);
    } else if (geom.getGeometryType().equals("GeometryCollection")) {
        GeometryCollection gc = (GeometryCollection)geom;
        Geometry[] geoms = new Geometry[gc.getNumGeometries()];
        for (int i = 0; i < gc.getNumGeometries(); i += 1) {
            geoms[i] = repair(gc.getGeometryN(i));
        }
        Thread.dumpStack();
        return factory.createGeometryCollection(geoms);
    } else {
        return(geom);
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:29,代碼來源:JTSUtil.java

示例2: removeCollinearVertices

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/**
 * Removes collinear vertices from the provided {@link Geometry}.
 * 
 * <p>
 * For the moment this implementation only accepts, {@link Polygon}, {@link LineString} and {@link MultiPolygon} It will throw an exception if the
 * geometry is not one of those types
 * 
 * @param g the instance of a {@link Geometry} to remove collinear vertices from.
 * @return a new instance of the provided {@link Geometry} without collinear vertices.
 */
public static Geometry removeCollinearVertices(final Geometry g) {
    if (g == null) {
        throw new NullPointerException("The provided Geometry is null");
    }
    if (g instanceof LineString) {
        return removeCollinearVertices((LineString) g);
    } else if (g instanceof Polygon) {
        return removeCollinearVertices((Polygon) g);
    } else if (g instanceof MultiPolygon) {
        MultiPolygon mp = (MultiPolygon) g;
        Polygon[] parts = new Polygon[mp.getNumGeometries()];
        for (int i = 0; i < mp.getNumGeometries(); i++) {
            Polygon part = (Polygon) mp.getGeometryN(i);
            part = removeCollinearVertices(part);
            parts[i] = part;
        }

        return g.getFactory().createMultiPolygon(parts);
    }

    throw new IllegalArgumentException(
            "This method can work on LineString, Polygon and Multipolygon: " + g.getClass());
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:34,代碼來源:JTS.java

示例3: checkShellsNotNested

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/**
 * Tests that no element polygon is wholly in the interior of another element polygon.
 * <p>
 * Preconditions:
 * <ul>
 * <li>shells do not partially overlap
 * <li>shells do not touch along an edge
 * <li>no duplicate rings exist
 * </ul>
 * This routine relies on the fact that while polygon shells may touch at one or
 * more vertices, they cannot touch at ALL vertices.
 */
private void checkShellsNotNested(MultiPolygon mp, GeometryGraph graph) {
    for (int i = 0; i < mp.getNumGeometries(); i++) {
        Polygon p = (Polygon) mp.getGeometryN(i);
        LinearRing shell = (LinearRing) p.getExteriorRing();
        for (int j = 0; j < mp.getNumGeometries(); j++) {
            if (i == j) {
                continue;
            }
            Polygon p2 = (Polygon) mp.getGeometryN(j);
            this.checkShellNotNested(shell, p2, graph);
            if (this.validErr != null) {
                return;
            }
        }
    }
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:29,代碼來源:IsValidOp.java

示例4: writeMultiPolygon

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
private void writeMultiPolygon(MultiPolygon mp, Writer writer, int level)
        throws IOException {
    this.startLine(level, writer);
    this.startGeomTag(GMLConstants.GML_MULTI_POLYGON, mp, writer);

    for (int t = 0; t < mp.getNumGeometries(); t++) {
        this.startLine(level + 1, writer);
        this.startGeomTag(GMLConstants.GML_POLYGON_MEMBER, null, writer);

        this.writePolygon((Polygon) mp.getGeometryN(t), writer, level + 2);

        this.startLine(level + 1, writer);
        this.endGeomTag(GMLConstants.GML_POLYGON_MEMBER, writer);
    }
    this.startLine(level, writer);
    this.endGeomTag(GMLConstants.GML_MULTI_POLYGON, writer);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:18,代碼來源:GMLWriter.java

示例5: appendMultiPolygonText

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/**
 * Converts a <code>MultiPolygon</code> to &lt;MultiPolygon Text&gt; format,
 * then appends it to the writer.
 *
 * @param multiPolygon the <code>MultiPolygon</code> to process
 * @param writer the output writer to append to
 */
private void appendMultiPolygonText(MultiPolygon multiPolygon, int level, Writer writer)
        throws IOException {
    if (multiPolygon.isEmpty()) {
        writer.write("EMPTY");
    } else {
        int level2 = level;
        boolean doIndent = false;
        writer.write("(");
        for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
            if (i > 0) {
                writer.write(", ");
                level2 = level + 1;
                doIndent = true;
            }
            this.appendPolygonText((Polygon) multiPolygon.getGeometryN(i), level2, doIndent, writer);
        }
        writer.write(")");
    }
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:27,代碼來源:WKTWriter.java

示例6: calcul3DArea

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
public double calcul3DArea(IGeometry geom) throws Exception {
  double area = -1;
  if (geom instanceof GM_OrientableSurface || geom instanceof GM_MultiSurface<?>) {
    // On la convertit en JTS
    Geometry geomJTS = JtsGeOxygene.makeJtsGeom(geom);
    if (geomJTS instanceof Polygon) {
      // Polygon on applique tout de suite
      area = area + this.calcul3DArea((Polygon) geomJTS);
    } else
      if (geomJTS instanceof MultiPolygon) {
        // MultiPolygon on l'applique par morceaux
        MultiPolygon multiP = (MultiPolygon) geomJTS;
        int nGeom = multiP.getNumGeometries();
        for (int j = 0; j < nGeom; j++) {
          area = area + this.calcul3DArea((Polygon) multiP.getGeometryN(j));
        }
      } else {
        // Type de géométrie non reconnue
        logger.warn("Geomtrie non reconnue" + geomJTS.getClass().toString());
      }
  } else {
    // Type de géométrie non reconnue
    logger.warn("Geomtrie non reconnue" + geom.getClass().toString());
  }
  return area;
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:27,代碼來源:DTMArea.java

示例7: toDoc

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
@Override
public ODocument toDoc(JtsGeometry shape) {

  ODocument doc = new ODocument(getName());
  MultiPolygon multiPolygon = (MultiPolygon) shape.getGeom();
  List<List<List<List<Double>>>> polyCoordinates = new ArrayList<List<List<List<Double>>>>();
  int n = multiPolygon.getNumGeometries();

  for (int i = 0; i < n; i++) {
    Geometry geom = multiPolygon.getGeometryN(i);
    polyCoordinates.add(coordinatesFromPolygon((Polygon) geom));
  }

  doc.field(COORDINATES, polyCoordinates);
  return doc;
}
 
開發者ID:orientechnologies,項目名稱:orientdb-spatial,代碼行數:17,代碼來源:OMultiPolygonShapeBuilder.java

示例8: simplify

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
public MultiPolygon simplify(MultiPolygon jtsMultiPolygon){
	int numGeomtries = jtsMultiPolygon.getNumGeometries();
	Polygon[] newPolys = new Polygon[numGeomtries];
	for (int i = 0; i < numGeomtries; i++){
		Geometry geom = jtsMultiPolygon.getGeometryN(i);
		if (geom instanceof Polygon){
		//if (geom.getGeometryType().equals("MultiPolygon")){
			Polygon poly = (Polygon)geom;
			Polygon newPoly = simplify(poly);
			newPolys[i] = newPoly;
		}else{
			throw new RuntimeException("geom is not a polygon, geom == "+geom);
		}
	}
	return new MultiPolygon(newPolys, this.geometryFactory);
}
 
開發者ID:rpax,項目名稱:straightedge,代碼行數:17,代碼來源:FogOfWarTest.java

示例9: getExteriorRing

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
@Override
public GamaShape getExteriorRing(final IScope scope) {

	// WARNING Only in 2D
	Geometry result = getInnerGeometry();
	if (result instanceof Polygon) {
		result = ((Polygon) result).getExteriorRing();
	} else

	if (result instanceof MultiPolygon) {
		final MultiPolygon mp = (MultiPolygon) result;
		final LineString lines[] = new LineString[mp.getNumGeometries()];
		for (int i = 0; i < mp.getNumGeometries(); i++) {
			lines[i] = ((Polygon) mp.getGeometryN(i)).getExteriorRing();
		}
		result = GeometryUtils.GEOMETRY_FACTORY.createMultiLineString(lines);

	}
	return new GamaShape(result);
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:21,代碼來源:GamaShape.java

示例10: doInBackground

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
@Override
protected Collection<PolygonOptions> doInBackground(Geometry... features) {  	
    Collection<PolygonOptions> polygons = new ArrayList<PolygonOptions>(features.length);
    for (Geometry feature : features) { 
        if (feature instanceof com.vividsolutions.jts.geom.Polygon) {      
        	polygons.add(generatePolygon((com.vividsolutions.jts.geom.Polygon)feature));                    
        }
        else if(feature instanceof com.vividsolutions.jts.geom.MultiPolygon) {                	
        	MultiPolygon multiPolygon = (MultiPolygon)feature;
        	for(int i = 0; i < multiPolygon.getNumGeometries(); i++) {
        		Geometry geometry = multiPolygon.getGeometryN(i);
        		if(geometry instanceof com.vividsolutions.jts.geom.Polygon) {
        			polygons.add(generatePolygon((com.vividsolutions.jts.geom.Polygon)geometry));
        		}
        		                		
        		//nested MultiPolygons are ignored for now.  Recursive solution has performance implications.                		
        	}                	
        }
    }    
    
    return polygons;
}
 
開發者ID:ngageoint,項目名稱:anti-piracy-android-app,代碼行數:23,代碼來源:OfflineMap.java

示例11: repair

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/** */
public static Geometry repair (Geometry geom) {
    GeometryFactory factory = geom.getFactory();
    if (geom instanceof MultiPolygon) {
        MultiPolygon mp = (MultiPolygon)geom;
        Polygon[] polys = new Polygon[mp.getNumGeometries()];
        for (int i = 0; i < mp.getNumGeometries(); i += 1) {
            polys[i] = repair((Polygon)mp.getGeometryN(i));
        }
        return factory.createMultiPolygon(polys);
    } else if (geom instanceof Polygon) {
        return repair((Polygon)geom);
    } else if (geom.getGeometryType().equals("GeometryCollection")) {
        GeometryCollection gc = (GeometryCollection)geom;
        Geometry[] geoms = new Geometry[gc.getNumGeometries()];
        for (int i = 0; i < gc.getNumGeometries(); i += 1) {
            geoms[i] = repair(gc.getGeometryN(i));
        }
        Thread.dumpStack();
        return factory.createGeometryCollection(geoms);
    } else {
        return(geom);
    }
}
 
開發者ID:reuven,項目名稱:modelingcommons,代碼行數:25,代碼來源:JTSUtils.java

示例12: doInBackground

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
@Override
protected List<PolygonOptions> doInBackground(Void... voids) {
    startTime = System.currentTimeMillis();
    Log.d(TAG, "transforming geometries to polygons");

    List<PolygonOptions> polygons = new ArrayList<>(features.size());

    for (Geometry feature : features) {
        // For now all offline map features are polygons
        if ("Polygon".equals(feature.getGeometryType())) {
            polygons.add(transformPolygon((com.vividsolutions.jts.geom.Polygon) feature));
        }
        else if ("MultiPolygon".equals(feature.getGeometryType())) {
            MultiPolygon mp = (MultiPolygon) feature;
            for (int i = 0; i < mp.getNumGeometries(); i++) {
                com.vividsolutions.jts.geom.Polygon polygon = (com.vividsolutions.jts.geom.Polygon) mp.getGeometryN(i);
                polygons.add(transformPolygon(polygon));
            }
        }
    }
    
    return polygons;
}
 
開發者ID:ngageoint,項目名稱:disconnected-content-explorer-android,代碼行數:24,代碼來源:OfflineMap.java

示例13: extractCoordinates

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
private static GeoJsonMultiPolygonCoordinateSet extractCoordinates(MultiPolygon multiPolygon) {
    GeoJsonMultiPolygonCoordinateSet multiPolygonCoordinateSet = new GeoJsonMultiPolygonCoordinateSet();
    for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
        Polygon polygon = (Polygon) multiPolygon.getGeometryN(i);
        GeoJsonPolygonCoordinateSet polygonCoordinateSet = new GeoJsonPolygonCoordinateSet();

        GeoJsonRingCoordinateSet exteriorRingCoordinateSet = getExteriorRingCoordinateSet(polygon);
        polygonCoordinateSet.add(exteriorRingCoordinateSet);

        for (int j = 0; j < polygon.getNumInteriorRing(); j++) {
            GeoJsonRingCoordinateSet interiorRingCoordinateSet = getInteriorRingCoordinateSet(polygon, j);
            polygonCoordinateSet.add(interiorRingCoordinateSet);
        }
        multiPolygonCoordinateSet.add(polygonCoordinateSet);
    }
    return multiPolygonCoordinateSet;
}
 
開發者ID:SEEG-Oxford,項目名稱:ABRAID-MP,代碼行數:18,代碼來源:GeoJsonMultiPolygonGeometry.java

示例14: getHealthMapCountryGeometryMap

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/**
 * Gets a mapping between HealthMap country ID and the geometry of the associated GAUL countries.
 * If the HealthMap country has no associated geometries, it does not appear in the map.
 * @return A mapping as described above.
 */
public Map<Integer, MultiPolygon> getHealthMapCountryGeometryMap() {
    if (healthMapCountryGeometryMap == null) {
        // This will retrieve the countries from the Hibernate cache if already obtained by HealthMapLookupData
        List<HealthMapCountry> countries = geometryService.getAllHealthMapCountries();
        healthMapCountryGeometryMap = new HashMap<>();

        for (HealthMapCountry country : countries) {
            if (country.getCountries() != null) {
                List<MultiPolygon> countryGeometries = extract(country.getCountries(), on(Country.class).getGeom());
                MultiPolygon countryGeometry = GeometryUtils.concatenate(countryGeometries);
                if (countryGeometry.getNumGeometries() > 0) {
                    healthMapCountryGeometryMap.put(country.getId(), countryGeometry);
                }
            }
        }
    }

    return healthMapCountryGeometryMap;
}
 
開發者ID:SEEG-Oxford,項目名稱:ABRAID-MP,代碼行數:25,代碼來源:QCLookupData.java

示例15: explodeMultiPolygon

import com.vividsolutions.jts.geom.MultiPolygon; //導入方法依賴的package包/類
/** */
public static GeometryCollection explodeMultiPolygon (MultiPolygon mp) {
    List<LinearRing> result = new ArrayList<LinearRing>(mp.getNumGeometries()*2);
    for (int i = 0; i < mp.getNumGeometries(); i += 1) {
        Polygon p = (Polygon)mp.getGeometryN(i);
        result.add((LinearRing)p.getExteriorRing());
        for (int j = 0; j < p.getNumInteriorRing(); j += 1) {
            result.add((LinearRing)p.getInteriorRingN(j));
        }
    }
    return mp.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(result));
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:13,代碼來源:JTSUtil.java


注:本文中的com.vividsolutions.jts.geom.MultiPolygon.getNumGeometries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。