本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.contains方法的具體用法?Java Geometry.contains怎麽用?Java Geometry.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.Geometry
的用法示例。
在下文中一共展示了Geometry.contains方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkIfTileIsOnLand
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* check if the tile is on land
*
* @param top
* @param left
* @param bottom
* @param right
* @return
*/
public boolean checkIfTileIsOnLand(double top,double left,double bottom,double right){
boolean isOnLand=false;
if(land!=null){
GeometryFactory fact = new GeometryFactory();
Coordinate[] cs=new Coordinate[5];
cs[0]=new Coordinate(top, left);
cs[1]=new Coordinate(bottom, left);
cs[2]=new Coordinate(top,right);
cs[3]=new Coordinate(bottom,right);
cs[4]=new Coordinate(top,left);
Polygon tile=fact.createPolygon(cs);
for (Geometry p : land) {
if (p.contains(tile)) {
isOnLand=true;
break;
}
}
}
return isOnLand;
}
示例2: contains
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public boolean contains(int x, int y) {
GeometryFactory gf = new GeometryFactory();
Point geom = gf.createPoint(new Coordinate(x, y));
for (Geometry p : maskGeometries) {
if (p.contains(geom)) {
return true;
}
}
return false;
}
示例3: rasterizeJTS
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
*/
public BufferedImage rasterizeJTS(Rectangle rect, int offsetX, int offsetY, double scalingFactor) {
// create the buffered image of the size of the Rectangle
BufferedImage image = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_BYTE_BINARY);
GeometryFactory gf = new GeometryFactory();
// define the clipping region in full scale
Coordinate[] coords = new Coordinate[]{
new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),};
Polygon geom = gf.createPolygon(gf.createLinearRing(coords));
for (Geometry p : maskGeometries) {
if (p.intersects(geom)) {
Geometry pg=p.intersection(geom).buffer(0);
//Coordinate[] coordsInter=gg.getCoordinates();
//Polygon pg=gf.createPolygon(coordsInter);
for(int x=0;x<rect.width;x++){
for(int y=0;y<rect.height;y++){
Point point=gf.createPoint(new Coordinate(rect.x+x,rect.y+y));
if(pg.contains(point)){
try{
image.setRGB(x,y, Color.WHITE.getRGB());
}catch(Exception e){
logger.error(e.getMessage()+" x:"+x+" y:"+y);
}
}
}
}
}
}
return image;
}
示例4: contains
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* check if the layer contains the geometry
* @param g
* @return
*/
public boolean contains(Geometry g) {
for (Geometry p : glayer.getGeometries()) {
if (p.contains(g)) {
return true;
}
}
return false;
}
示例5: buffer
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* create the new buffered layer
*/
public void buffer(double bufferingDistance) {
List<Geometry> bufferedGeom=glayer.getGeometries();
try {
bufferedGeom=parallelBuffer(bufferedGeom, bufferingDistance);
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
// then merge them
List<Geometry> newgeoms = new ArrayList<Geometry>();
List<Geometry> remove = new ArrayList<Geometry>();
// if(bufferingDistance>0){
//ciclo sulle nuove geometrie
for (Geometry buffGeom : bufferedGeom) {
boolean isnew = true;
remove.clear();
for (Geometry newg : newgeoms) {
if (newg.contains(buffGeom)) { //se newg contiene g -> g deve essere rimossa
isnew = false;
break;
} else if (buffGeom.contains(newg)) { //se g contiene newg -> newg deve essere rimossa
remove.add(newg);
}
}
if (isnew) {
newgeoms.add(buffGeom);
}
newgeoms.removeAll(remove);
}
glayer.clear();
// assign new value
for (Geometry geom :newgeoms) {
glayer.put(geom);
}
// }
}