当前位置: 首页>>代码示例>>Java>>正文


Java IsValidOp.isValid方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.operation.valid.IsValidOp.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java IsValidOp.isValid方法的具体用法?Java IsValidOp.isValid怎么用?Java IsValidOp.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.operation.valid.IsValidOp的用法示例。


在下文中一共展示了IsValidOp.isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:59,代码来源:PolygonGenerator.java

示例2: 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");
  }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:12,代码来源:IsValidTester.java

示例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 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;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:65,代码来源:LineStringGenerator.java

示例4: 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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:13,代码来源:Geometry.java

示例5: 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);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:13,代码来源:Geometry.java

示例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);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:15,代码来源:Geometry.java


注:本文中的com.vividsolutions.jts.operation.valid.IsValidOp.isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。