Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryFactory


  private static Geometry addIntersectionVertexToLine(Geometry lineToAddVertex, Geometry line) {

    Geometry result = null;

    List<Coordinate> shellCoordinates = null;
    GeometryFactory fc = lineToAddVertex.getFactory();
    Geometry boundary = lineToAddVertex.getBoundary();

    Coordinate[] boundaryCoordinates = boundary.getCoordinates();

    // add the intersection vertex to the shellCoordinates.
    shellCoordinates = addIntersection(boundaryCoordinates, line, fc, line);

    Coordinate[] shellClosed = shellCoordinates.toArray(new Coordinate[shellCoordinates.size()]);
    shellClosed = GeometryUtil.closeGeometry(shellClosed);

    result = fc.createLineString(shellClosed);

    return result;
  }
View Full Code Here


  @Before
  public void setUp() throws Exception {
    type1=DataUtilities.createType("type1", "geom1:LineString,name:String,id:int,geom2:Point")//$NON-NLS-1$//$NON-NLS-2$
    type2=DataUtilities.createType("type2", "geom2:Point,name:String"); //$NON-NLS-1$ //$NON-NLS-2$
   
    GeometryFactory fac=new GeometryFactory();
    point=fac.createPoint(new Coordinate(10,10));
   
    line=fac.createLineString(new Coordinate[]{
      new Coordinate(20,20), new Coordinate(30,30
    });
   
    name="Name"; //$NON-NLS-1$
    id=1;
     
    original=SimpleFeatureBuilder.build( type1, new Object[]{
        line,name,id,point
    }, null);
    newPoint=fac.createPoint(new Coordinate(0,0));
    wrapped=new FeatureWrapper(original,type2, new Geometry[]{newPoint}, new String[]{"geom2"}); //$NON-NLS-1$
  }
View Full Code Here

    public CoordinateReferenceSystem getCRS() {
        return getViewportModel().getCRS();
    }

    public Shape toShape( ReferencedEnvelope envelope ) {
        return toShape(new GeometryFactory().toGeometry(envelope), envelope.getCoordinateReferenceSystem());
    }
View Full Code Here

                bbox = JTS.transform(boundingBox, transform);
            } catch (Exception e) {
                bbox = boundingBox;
            }
            String geom = getSchema().getGeometryDescriptor().getName().getLocalPart();
            Object bboxGeom = new GeometryFactory().toGeometry(bbox);
            bboxFilter = factory.intersects(factory.property(geom), factory.literal(bboxGeom));

        } catch (Exception e) {
            ProjectPlugin.getPlugin().log(e);
        }
View Full Code Here

    @Override
    public Geometry getGeometry() {
        ReferencedEnvelope extent = this.getExtent();
        if (extent != null) {
            return new GeometryFactory().toGeometry(extent);
        }
        return null;
    }
View Full Code Here

    @Test
    public void testBC_ALBERS_Viewport() throws Exception {
        CRSFactory fac = (CRSFactory) ReferencingFactoryFinder.getCRSFactories(null).iterator().next();
        CoordinateReferenceSystem crs = fac.createFromWKT(BC_ALBERS_WKT);
       
        GeometryFactory gfac = new GeometryFactory();
       
        double maxx = -120;
        double maxy = 59.9;
        double minx = -125;
        double miny = 50;
        LineString linestring = gfac.createLineString(new Coordinate[]{
                new Coordinate(minx,miny),
                new Coordinate(maxx,maxy)
        });
       
        linestring=(LineString) JTS.transform(linestring, CRS.findMathTransform(DefaultGeographicCRS.WGS84, crs, true));
View Full Code Here

        return geocoder;
    }
   
    /** Returns a List<SimpleFeature> of ADDRESS */
    public Point where(String address) throws IOException,XmlRpcException {
        GeometryFactory fac = new GeometryFactory();       
        XmlRpcClient geocoder = getGeoCoderClient(username, password);
       
        Vector params = new Vector();
        params.addElement(address);
        // this method returns a string
        Vector vec = (Vector)geocoder.execute("geocode", params); //$NON-NLS-1$
        System.out.println("vec"+vec); //$NON-NLS-1$
       
        Hashtable table = (Hashtable)vec.get(0);
        double lat = ((Number)table.get("lat")).doubleValue(); //$NON-NLS-1$
        double lon = ((Number)table.get("long")).doubleValue(); //$NON-NLS-1$
        Coordinate c = new Coordinate(lon, lat);
        Point p = fac.createPoint(c);
        return p;
    }
View Full Code Here

        Point p = fac.createPoint(c);
        return p;
    }
   
    public List<SimpleFeature> geocode(String address) throws IOException,XmlRpcException {
        GeometryFactory fac = new GeometryFactory();     
        XmlRpcClient geocoder = getGeoCoderClient(username, password);
       
        Vector params = new Vector();
        params.addElement(address);
       
        // this method returns a string
        Vector<Hashtable<String,Object>> vec = (Vector<Hashtable<String,Object>>)geocoder.execute("geocode", params); //$NON-NLS-1$
        System.out.println("vec"+vec); //$NON-NLS-1$

        List<String> keys = keys( vec );
        SimpleFeatureType ADDRESS = createAddressType( keys );
       
        List<SimpleFeature> places = new ArrayList<SimpleFeature>( vec.size() );

        int count=1;
        for( Hashtable table : vec ){
            double lat = Double.NaN, lon = Double.NaN;
            Object values[] = new Object[keys.size()-1];
            int index = 0;
            for( String key : keys ){
                if( !table.containsKey( key )){
                    System.out.println("missed key - "+key ); //$NON-NLS-1$
                    continue;
                }
                else {
                        if( "lat".equals( key ) ){ //$NON-NLS-1$
                            lat = ((Number)table.get("lat")).doubleValue(); //$NON-NLS-1$
                            continue;
                        }
                        else if( "long".equals( key ) ){ //$NON-NLS-1$
                            lon = ((Number)table.get("long")).doubleValue(); //$NON-NLS-1$
                            continue;
                        }               
                        values[index] = table.get( key );
                }
                index++;
            }
            if( Double.isNaN( lat ) || Double.isNaN( lon )){
                System.out.println("missed location - " );                 //$NON-NLS-1$
            }
            else {
                values[index] = fac.createPoint( new Coordinate(lon, lat) );
            }
            try{
                SimpleFeature f = SimpleFeatureBuilder.build(ADDRESS, values, fid( count++, table ) );
                places.add( f );
            } catch(Exception e){
View Full Code Here

     */
    @Ignore
    @Test
    public void testOverlapsOp() throws Exception {
        //create features suitable for the test
        GeometryFactory factory = new GeometryFactory();
        LineString[] line = new LineString[4];
        // first test: 2 overlapping lines, overlap test fails?
        line[0] = factory.createLineString(new Coordinate[]{new Coordinate(10, 10),
                new Coordinate(20, 20),});
        line[1] = factory.createLineString(new Coordinate[]{new Coordinate(15, 15),
                new Coordinate(25, 25),});
        assertTrue(line[0].overlaps(line[1])); // just checking :)
        // second test: does this validation test for self-overlaps? (it shouldn't)
        line[2] = factory.createLineString(new Coordinate[]{new Coordinate(50, 50),
                new Coordinate(60, 50), new Coordinate(55, 50),});
        // third test: an intersecting line; is valid? 
        line[3] = factory.createLineString(new Coordinate[]{new Coordinate(10, 20),
                new Coordinate(20, 10),});

        String[] attrValues = new String[4];
        attrValues[0] = "value0"; //$NON-NLS-1$
        attrValues[1] = "value1"; //$NON-NLS-1$
View Full Code Here

    @Before
    public void setUp() throws Exception {
        map=MapTests.createDefaultMap("Test",3,true,new Dimension(500,500)); //$NON-NLS-1$
        FeatureStore<SimpleFeatureType, SimpleFeature> resource = map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
        features=resource.getFeatures();
        GeometryFactory fac=new GeometryFactory();
        int i=0;
        for( FeatureIterator<SimpleFeature> iter=features.features(); iter.hasNext(); ){
            i++;
            SimpleFeature feature=iter.next();
            Coordinate c=map.getViewportModel().pixelToWorld(i*10,0);
            FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
      Set<Identifier> ids = new HashSet<Identifier>();
      ids.add(filterFactory.featureId(feature.getID()));
      GeometryDescriptor defaultGeometry = feature.getFeatureType().getGeometryDescriptor();
      resource.modifyFeatures(defaultGeometry, fac.createPoint(c),
                    filterFactory.id(ids));
        }
        ((EditManager)map.getEditManager()).commitTransaction();

        handler=new TestHandler();
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.GeometryFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.