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


Java GeometryFactory.createPoint方法代碼示例

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


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

示例1: GeometryImage

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 *
 * @param name
 * @param type
 * @param geoms
 */
public GeometryImage(String name,String type,List<Coordinate>geoms) {
	this.type=type;
	this.name=name;

	this.geoms=new ArrayList<>();
	//attsMap=new HashMap<>();
       GeometryFactory gf = new GeometryFactory();
       for(Coordinate c:geoms){
       	AttributesGeometry att = new AttributesGeometry(new String[]{"x","y"});
       	att.set("x",c.x);
       	att.set("y",c.y);
       	Geometry gg=gf.createPoint(c);
       	put(gg, att);
       }
   }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:22,代碼來源:GeometryImage.java

示例2: contains

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的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;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:11,代碼來源:MaskGeometries.java

示例3: mouseClicked

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 *
 * @param imagePosition
 * @param context
 */
public void mouseClicked(java.awt.Point imagePosition, OpenGLContext context) {
	if(isEditable()){
     this.selectedGeometry = null;
     GeometryFactory gf = new GeometryFactory();
     com.vividsolutions.jts.geom.Point p = gf.createPoint(new Coordinate(imagePosition.x, imagePosition.y));
     for (Geometry temp : glayer.getGeometries()) {
     	if(temp instanceof Polygon){
      	Coordinate[] c=DistanceOp.nearestPoints(temp, p);
      	com.vividsolutions.jts.geom.Point nearest=gf.createPoint(c[0]);
          if (nearest.isWithinDistance(temp,5 * context.getZoom())) {
              this.selectedGeometry = temp;
              System.out.println(""+temp.getCoordinate().x+","+temp.getCoordinate().y);
              LayerPickedData.put(temp, glayer.getAttributes(temp));
              break;
          }
     	}
     }
	}
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:25,代碼來源:MaskVectorLayer.java

示例4: getShape

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
private Geometry getShape(CSVRecord record) {
    if (!config.getGeographyProjection().equals("") &&
            config.getGeographyXIndex() != -1 &&
            config.getGeographyYIndex() != -1) {

        GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), Subject.SRID);

        Coordinate coordinate = null;
        Double x = Double.parseDouble(record.get(config.getGeographyXIndex()));
        Double y = Double.parseDouble(record.get(config.getGeographyYIndex()));
        if (config.getGeographyProjection().equals(CoordinateUtils.WGS84CRS)) {

            coordinate = new Coordinate(x, y);
        } else {
            try {
                coordinate = CoordinateUtils.eastNorthToLatLong(x, y, config.getGeographyProjection(), CoordinateUtils.WGS84CRS);
            } catch (Exception e) {
                log.warn("Coordinates will not be considered: " + e.getMessage());
                return null;
            }
        }
        return geometryFactory.createPoint(coordinate);
    }

    return null;
}
 
開發者ID:FutureCitiesCatapult,項目名稱:TomboloDigitalConnector,代碼行數:27,代碼來源:GeneralCSVImporter.java

示例5: edit

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
@Override
public final Geometry edit(Geometry geometry, GeometryFactory factory) {
    if (geometry instanceof LinearRing) {
        return factory.createLinearRing(this.edit(geometry.getCoordinates(),
                geometry));
    }

    if (geometry instanceof LineString) {
        return factory.createLineString(this.edit(geometry.getCoordinates(),
                geometry));
    }

    if (geometry instanceof Point) {
        Coordinate[] newCoordinates = this.edit(geometry.getCoordinates(),
                geometry);

        return factory.createPoint((newCoordinates.length > 0)
                ? newCoordinates[0] : null);
    }

    return geometry;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:23,代碼來源:GeometryEditor.java

示例6: getUserEntityFromDto

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * Map user data transfer object into user entity
 * 
 * @param userDTO User Data Transfer object
 * @return User
 */	
public User getUserEntityFromDto(UserDTO userDTO){
	User user = map(userDTO, User.class);
	
	if (userDTO.getLatitude() != null && userDTO.getLongitude() != null){
		GeometryFactory gf = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING));
		Coordinate coordinate = new Coordinate(Double.parseDouble(userDTO.getLongitude()),
				Double.parseDouble(userDTO.getLatitude()));
		com.vividsolutions.jts.geom.Point point = gf.createPoint(coordinate);	
		user.setLocation(point);			
	}
	user.setDisplayFlag(Boolean.valueOf(userDTO.getDisplayFlag()));
	return user;
}
 
開發者ID:Code4SocialGood,項目名稱:C4SG-Obsolete,代碼行數:20,代碼來源:UserMapper.java

示例7: rasterizeJTS

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的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;

}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:43,代碼來源:MaskGeometries.java

示例8: contains

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public boolean contains(int x, int y) {
    if (getType().equals(GeometryImage.POINT)) {
        return false;
    }
    GeometryFactory gf = new GeometryFactory();
    Point geom = gf.createPoint(new Coordinate(x, y));
    for (Geometry p : glayer.getGeometries()) {
        if (p.contains(geom)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:14,代碼來源:MaskVectorLayer.java

示例9: mouseClicked

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * 
 * @param imagePosition
 * @param context
 */
public void mouseClicked(java.awt.Point imagePosition,Object glContext) {
	OpenGLContext context=(OpenGLContext)glContext;
    this.selectedGeometry = null;
    GeometryFactory gf = new GeometryFactory();
    com.vividsolutions.jts.geom.Point p = gf.createPoint(new Coordinate(imagePosition.x, imagePosition.y));
    for (Geometry temp : glayer.getGeometries()) {
        //if (p.equalsExact(temp, 5 * context.getZoom())) {
        if (p.equalsExact(temp, 5 * context.getZoom())) {	
            this.selectedGeometry = temp;
            //System.out.println(""+temp.getCoordinate().x+","+temp.getCoordinate().y);
            LayerPickedData.put(temp, glayer.getAttributes(temp));
        }
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:20,代碼來源:EditGeometryVectorLayer.java

示例10: mouseClicked

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public void mouseClicked(java.awt.Point imagePosition, int button,Object graphicContext) {
	OpenGLContext context=(OpenGLContext)graphicContext;
    this.selectedGeometry = null;
    GeometryFactory gf = new GeometryFactory();
    Point p = gf.createPoint(new Coordinate(imagePosition.x, imagePosition.y));
    for (Point temp : interpolated) {
        if (temp.isWithinDistance(p, 5 * context.getZoom())) {
            this.selectedGeometry = temp;
            LayerPickedData.put(temp, glayer.getAttributes(temp));
        }
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:13,代碼來源:InterpolatedVectorLayer.java

示例11: get

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public BufferedImage get(Point position) {
    GeometryFactory gf = new GeometryFactory();
    com.vividsolutions.jts.geom.Point p = gf.createPoint(new Coordinate(position.x, position.y));
    for (Geometry temp : glayer.getGeometries()) {
        if (temp.isWithinDistance(p, 5 * thumbReader.getWidth() / 512f)) {
            BufferedImage image=tmanager.get(glayer.getAttributes(temp).get(id).toString());
            return rescale.filter(image,image);
        }
    }
    return null;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:12,代碼來源:ThumbnailsLayer.java

示例12: readLayer

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public GeometryImage readLayer() {
	GeometryImage layer=null;
    try {
        layer = new GeometryImage(GeometryImage.POINT);
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(input);

        GeometryFactory gf = new GeometryFactory();
        Element root = doc.getRootElement();
                   
        if (root != null) {

            layer.setProjection("EPSG:4326");
            layer.setName(input.getName());
            for (Object obj : root.getChildren()) {
                if (obj instanceof Element) {
                    Element feature = (Element) obj;
                                                                 
                    if (feature.getName().equals("featureMember")) {
                        Namespace vd=Namespace.getNamespace("vd", "http://cweb.ksat.no/cweb/schema/vessel");
                        Namespace gml=Namespace.getNamespace("gml", "http://www.opengis.net/gml");
                        Element vessel = feature.getChild("feature",vd).getChild("vessel",vd);
                        AttributesGeometry atts = new  AttributesGeometry(VDSSchema.schema);
                        String point[] = vessel.getChild("Point",gml).getChild("pos",gml).getText().split(" ");
                        double lon = Double.parseDouble(point[0]);                            
                        double lat = Double.parseDouble(point[1]);
                        Geometry geom = gf.createPoint(new Coordinate(lat, lon));
                        layer.put(geom, atts);
                        try {
                            atts.set(VDSSchema.ID, Double.parseDouble(feature.getChild("feature",vd).getChild("name",gml).getValue()));
                            atts.set(VDSSchema.ESTIMATED_LENGTH, Double.parseDouble(vessel.getChild("length",vd).getValue()));
                            atts.set(VDSSchema.ESTIMATED_WIDTH, Double.parseDouble(vessel.getChild("beam",vd).getValue()));
                            atts.set(VDSSchema.ESTIMATED_HEADING, Double.parseDouble(vessel.getChild("heading",vd).getValue()));
                        } catch (Exception e) {
                            //e.printStackTrace();
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
    	logger.error(ex.getMessage(),ex);
    }
    return layer;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:46,代碼來源:GmlIO.java

示例13: testEquals

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * Test equality method on ValueGeometry
 */
private void testEquals() {
    // 3d equality test
    ValueGeometry geom3d = ValueGeometry.get(
            "POLYGON ((67 13 6, 67 18 5, 59 18 4, 59 13 6,  67 13 6))");
    ValueGeometry geom2d = ValueGeometry.get(
            "POLYGON ((67 13, 67 18, 59 18, 59 13,  67 13))");
    assertFalse(geom3d.equals(geom2d));
    // SRID equality test
    GeometryFactory geometryFactory = new GeometryFactory();
    Geometry geometry = geometryFactory.createPoint(new Coordinate(0, 0));
    geometry.setSRID(27572);
    ValueGeometry valueGeometry =
            ValueGeometry.getFromGeometry(geometry);
    Geometry geometry2 = geometryFactory.createPoint(new Coordinate(0, 0));
    geometry2.setSRID(5326);
    ValueGeometry valueGeometry2 =
            ValueGeometry.getFromGeometry(geometry2);
    assertFalse(valueGeometry.equals(valueGeometry2));
    // Check illegal geometry (no WKB representation)
    try {
        ValueGeometry.get("POINT EMPTY");
        fail("expected this to throw IllegalArgumentException");
    } catch (IllegalArgumentException ex) {
        // expected
    }
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:30,代碼來源:TestSpatial.java

示例14: points

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public static Geometry points(List<Coordinate> coordinates,
                              GeometryFactory factory) {
    if (coordinates.size() == 1) {
        return factory.createPoint(coordinates.get(0));
    }
    return factory.createMultiPoint(coordinates
            .toArray(new Coordinate[coordinates.size()]));
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:9,代碼來源:GeometryUtil.java

示例15: convertUTM_MGA942Geographic_EPSG4326

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public static Geometry convertUTM_MGA942Geographic_EPSG4326(Double easting, Double northing, String zone) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException, TransformException{
	CoordinateReferenceSystem geographic = CRS.decode("EPSG:4326", false);
	CoordinateReferenceSystem geographic2 = ReferencingFactoryFinder.getCRSAuthorityFactory(
			"EPSG", null).createCoordinateReferenceSystem("4326");
	

	
	CoordinateReferenceSystem utm = ReferencingFactoryFinder.getCRSAuthorityFactory(
			"EPSG", null).createCoordinateReferenceSystem("283"+zone);
	
	CoordinateOperationFactory coFactory = ReferencingFactoryFinder
			.getCoordinateOperationFactory(null);
	
	CoordinateReferenceSystem sourceCRS = utm;		
	CoordinateReferenceSystem targetCRS = geographic;

	GeometryFactory gf = new GeometryFactory();
       Coordinate coord = new Coordinate( easting, northing );
       Point point = gf.createPoint( coord );
       
	
	MathTransform mathTransform =CRS.findMathTransform( sourceCRS, targetCRS,true );
	Geometry g2 = JTS.transform(point, mathTransform);
	
	//VT: Flip around to correct the lat lon from the utm to geographic transformation
	Coordinate[] original = g2.getCoordinates();
	for(int i = 0; i < original.length; i++){
	    Double swapValue = original[i].x;
	    original[i].x = original[i].y;
	    original[i].y = swapValue;
	}
    
	return g2;
}
 
開發者ID:AuScope,項目名稱:igsn30,代碼行數:35,代碼來源:SpatialUtilities.java


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