本文整理汇总了Java中com.vividsolutions.jts.operation.valid.IsValidOp类的典型用法代码示例。如果您正苦于以下问题:Java IsValidOp类的具体用法?Java IsValidOp怎么用?Java IsValidOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IsValidOp类属于com.vividsolutions.jts.operation.valid包,在下文中一共展示了IsValidOp类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkJTSFootprint
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
/**
* Check JTS Footprint validity
*/
public static boolean checkJTSFootprint (String footprint)
{
try
{
WKTReader wkt = new WKTReader();
Geometry geom = wkt.read(footprint);
IsValidOp vaildOp = new IsValidOp(geom);
TopologyValidationError err = vaildOp.getValidationError();
if (err != null)
{
throw new IllegalParameterException(err.getMessage());
}
return true;
}
catch (Exception e)
{
LOGGER.error("JTS Footprint error : " + e.getMessage());
return false;
}
}
示例2: testCountryBoundariesGeoJson
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
public void testCountryBoundariesGeoJson() throws IOException
{
String geoJson = StreamUtils.readToString(getContext().getAssets().open("countryBoundaries.json"));
GeometryCollection countriesBoundaries = (GeometryCollection) new GeoJsonReader().read(geoJson);
for(int i = 0; i < countriesBoundaries.getNumGeometries(); ++i)
{
Geometry countryBoundary = countriesBoundaries.getGeometryN(i);
Map<String,String> props = (Map<String,String>) countryBoundary.getUserData();
TopologyValidationError err = new IsValidOp(countryBoundary).getValidationError();
if(err != null) {
String countryCode = props.get("ISO3166-1:alpha2");
if(countryCode == null) countryCode = props.get("ISO3166-2");
fail("" + countryCode + ": " + err.toString());
}
}
}
示例3: create
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
/**
* As the user increases the number of points, the probability of creating a random valid polygon decreases.
* Please take not of this when selecting the generation style, and the number of points.
*
* May return null if a geometry could not be created.
*
* @see #getNumberPoints()
* @see #setNumberPoints(int)
* @see #getGenerationAlgorithm()
* @see #setGenerationAlgorithm(int)
*
* @see #BOX
* @see #ARC
*
* @see com.vividsolutions.jts.generator.GeometryGenerator#create()
*
* @throws IllegalStateException When the alg is not valid or the number of points is invalid
* @throws NullPointerException when either the Geometry Factory, or the Bounding Box are undefined.
*/
public Geometry create() {
if(geometryFactory == null){
throw new NullPointerException("GeometryFactory is not declared");
}
if(boundingBox == null || boundingBox.isNull()){
throw new NullPointerException("Bounding Box is not declared");
}
if(numberPoints<4){
throw new IllegalStateException("Too few points");
}
double x = boundingBox.getMinX(); // base x
double dx = boundingBox.getMaxX()-x;
double y = boundingBox.getMinY(); // base y
double dy = boundingBox.getMaxY()-y;
Polygon p = null;
for(int i=0;i<RUNS;i++){
switch(getGenerationAlgorithm()){
case BOX:
p = createBox(x,dx,y,dy,numberHoles,numberPoints,geometryFactory);
break;
case ARC:
p = createArc(x,dx,y,dy,numberHoles,numberPoints,geometryFactory);
break;
default:
throw new IllegalStateException("Invalid Alg. Specified");
}
IsValidOp valid = new IsValidOp(p);
if(valid.isValid()){
return p;
}
}
return null;
}
示例4: main
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
WKTReader reader = new WKTReader(new GeometryFactory());
Geometry g = reader.read("GEOMETRYCOLLECTION (POINT (110 300), POINT (100 110), POINT (130 210), POINT (150 210), POINT (150 180), POINT (130 170), POINT (140 190), POINT (130 200), LINESTRING (240 50, 210 120, 270 80, 250 140, 330 70, 300 160, 340 130, 340 130), POLYGON ((210 340, 220 260, 150 270, 230 220, 230 140, 270 210, 360 240, 260 250, 260 280, 240 270, 210 340), (230 270, 230 250, 200 250, 240 220, 240 190, 260 220, 290 230, 250 230, 230 270)))");
IsValidOp op = new IsValidOp(g);
if (!op.isValid()) {
System.out.println(op.getValidationError().getMessage());
}
else {
System.out.println("OK");
}
}
示例5: create
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
/**
* As the user increases the number of points, the probability of creating a random valid linestring decreases.
* Please take not of this when selecting the generation style, and the number of points.
*
* May return null if a geometry could not be created.
*
* @see #getNumberPoints()
* @see #setNumberPoints(int)
* @see #getGenerationAlgorithm()
* @see #setGenerationAlgorithm(int)
*
* @see #VERT
* @see #HORZ
* @see #ARC
*
* @see com.vividsolutions.jts.generator.GeometryGenerator#create()
*
* @throws IllegalStateException When the alg is not valid or the number of points is invalid
* @throws NullPointerException when either the Geometry Factory, or the Bounding Box are undefined.
*/
public Geometry create() {
if(geometryFactory == null){
throw new NullPointerException("GeometryFactory is not declared");
}
if(boundingBox == null || boundingBox.isNull()){
throw new NullPointerException("Bounding Box is not declared");
}
if(numberPoints<2){
throw new IllegalStateException("Too few points");
}
Coordinate[] coords = new Coordinate[numberPoints];
double x = boundingBox.getMinX(); // base x
double dx = boundingBox.getMaxX()-x;
double y = boundingBox.getMinY(); // base y
double dy = boundingBox.getMaxY()-y;
for(int i=0;i<RUNS;i++){
switch(getGenerationAlgorithm()){
case VERT:
fillVert(x,dx,y,dy,coords,geometryFactory);
break;
case HORZ:
fillHorz(x,dx,y,dy,coords,geometryFactory);
break;
case ARC:
fillArc(x,dx,y,dy,coords,geometryFactory);
break;
default:
throw new IllegalStateException("Invalid Alg. Specified");
}
LineString ls = geometryFactory.createLineString(coords);
IsValidOp valid = new IsValidOp(ls);
if(valid.isValid()){
return ls;
}
}
return null;
}
示例6: isValid
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
/**
* Tests whether this <code>Geometry</code>
* is topologically valid, according to the OGC SFS specification.
* <p>
* For validity rules see the Javadoc for the specific Geometry subclass.
*
* @return <code>true</code> if this <code>Geometry</code> is valid
* @see IsValidOp
*/
public boolean isValid() {
return IsValidOp.isValid(this);
}
示例7: isValid
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
/**
* Tests whether this <code>Geometry</code>
* is topologically valid, according to the OGC SFS specification.
* <p/>
* For validity rules see the Javadoc for the specific Geometry subclass.
*
* @return <code>true</code> if this <code>Geometry</code> is valid
* @see IsValidOp
*/
public boolean isValid() {
return IsValidOp.isValid(this);
}
示例8: isValid
import com.vividsolutions.jts.operation.valid.IsValidOp; //导入依赖的package包/类
/**
* Tests whether this <code>Geometry</code>
* is topologically valid, according to the OGC SFS specification.
* <p>
* For validity rules see the Javadoc for the specific Geometry subclass.
*
*@return <code>true</code> if this <code>Geometry</code> is valid
*
* @see IsValidOp
*/
public boolean isValid()
{
return IsValidOp.isValid(this);
}