Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Geometry


   */
  public void add(Collection geometries)
  {
    mergedLineStrings = null;
    for (Iterator i = geometries.iterator(); i.hasNext(); ) {
      Geometry geometry = (Geometry) i.next();
      add(geometry);
    }
  }
View Full Code Here


      coords[i] = c;
    }
   
    // now create a line string from the coordinates array where null = no holes in the polygon
    LinearRing ring = new GeometryFactory().createLinearRing(coords);
    Geometry geometry = new GeometryFactory().createPolygon(ring, null);
   
    // Note: the centroid for the ZoneDetail vertices is never
    // stored in the database. It was just as easy to calculate
    // it on the fly in ZoneDAO.getZoneDetails()
   
View Full Code Here

      coords[i] = c;
    }
   
    // now create a line string from the coordinates array where null = no holes in the polygon
    LinearRing ring = new GeometryFactory().createLinearRing(coords);
    Geometry geometry = new GeometryFactory().createPolygon(ring, null);
   
    // create a point from the mapCenter vertex
    // TODO: mapCenter is null when creating a new study region.
    Vertex mapCenterVertex = studyRegion.getMapCenter();
    logger.debug("mapCenter=" + studyRegion.getMapCenter());
    Coordinate mapCenterCoord = new Coordinate(mapCenterVertex.getLng(), mapCenterVertex.getLat());
    Geometry mapCenter = new GeometryFactory().createPoint(mapCenterCoord);
   
    StudyRegion savedStudyRegion = null;
   
    try {
      if( studyRegion.getId().indexOf("TEMP") != -1 )
View Full Code Here

@FacesConverter(forClass = Geometry.class)
public class GeometryConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Geometry geom = null;
        if (value != null) {
            try {
                WKTReader reader = new WKTReader();
                geom = reader.read(value);
                geom.setSRID(4326);
            } catch (ParseException ex) {
                Logger.getLogger(GeometryConverter.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
View Full Code Here

@FacesConverter(forClass = Geometry.class)
public class GeometryConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Geometry geom = null;
        if (value != null) {
            try {
                WKTReader reader = new WKTReader();
                geom = reader.read(value);
                geom.setSRID(4326);
            } catch (ParseException ex) {
                Logger.getLogger(GeometryConverter.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
View Full Code Here

        ILayer nextLayer = strategy.getNextLayer();
       
        ILayer selectedLayer = activeLayer;
       
        // change the layer we are looking at based on navigation
        Geometry geometry = strategy.getGeometry();
        Polygon testLocation = JTS.toGeometry(this.bbox);
        if(isNavigate && (mouseEvent.button == MapMouseEvent.BUTTON3)){
            if( previousLayer != null ){
                selectedLayer = previousLayer;
            }
            else {
                // end of the world!
                updateAOIService(null, null);
                bounds = getMap().getBounds(null);
                ViewportModelImpl vmi = (ViewportModelImpl) getMap().getViewportModel();
                vmi.zoomToBox(bounds);
                return;
            }
        }
        else if (isNavigate && (mouseEvent.button == MapMouseEvent.BUTTON1)) {
            selectedLayer = nextLayer != null ? nextLayer : activeLayer;
            if( activeLayer != null ){
                // please stay on the active layer until you have a geometry
                if( geometry == null || !geometry.contains( testLocation)){
                    // we need a selected geometry before we let people navigate away
                    selectedLayer = activeLayer;
                }
            }
        }
       
        if( selectedLayer == null){
            return; // nothing to do!
        }
        if (!selectedLayer.getInteraction(Interaction.AOI)){
            return; // eek!
        }
        // use the bbox to see if we hit anything!
        SimpleFeatureCollection featureCollection = getFeaturesInBbox(selectedLayer, bbox, monitor);
       
        if (featureCollection.isEmpty()) {
            // the user did not click on anything useful (so sad)!
            // see if they were trying to click around on the active layer instead!
            if( selectedLayer == activeLayer){
                return; // give up no change to AOI stuffs
            }
            else {
                // quickly test to see if they clicked on a neighbour
                SimpleFeatureCollection testCollection = getFeaturesInBbox(activeLayer, bbox, monitor);
                if(!testCollection.isEmpty() ){
                    // okay let us go to neighbour
                    selectedLayer = activeLayer;
                    featureCollection = testCollection;
                }
                else {
                    return; // user really did not find anything to click on
                }
            }
        }       
        bounds = featureCollection.getBounds();
        Geometry newAOI = unionGeometry(featureCollection);
       
        updateAOIService(selectedLayer,newAOI );

        if (isNavigate) {
            IMap map = selectedLayer.getMap();
View Full Code Here

        List<Geometry> geoms = new ArrayList<Geometry>();
        SimpleFeatureIterator featureIterator = featureCollection.features();

        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            geoms.add(geometry.reverse());

        }

        GeometryFactory factory = new GeometryFactory();
        Geometry combined = factory.buildGeometry(geoms);

        return combined.union();
    }
View Full Code Here

     * (non-Javadoc)
     * @see org.locationtech.udig.aoi.IAOIStrategy#getExtent()
     */
    @Override
    public ReferencedEnvelope getExtent() {
        Geometry geometry = getGeometry();
        if (geometry != null){
            CoordinateReferenceSystem crs = getCrs();
            return new ReferencedEnvelope(geometry.getEnvelopeInternal(), crs);
        }
        return null;
    }
View Full Code Here

        ILayer victim = getActiveLayer();
        if( victim == null ){
            return null;
        }
        IBlackboard blackboard = victim.getBlackboard();
        Geometry geometry = (Geometry) blackboard.get(AOI_GEOMETRY );
        return geometry;
    }
View Full Code Here

                        if( wkt != null ){
                            // we got one!
                            GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null);
                            WKTReader reader = new WKTReader(gf);
                            try {
                                Geometry geometry = reader.read(wkt);
                                blackboard.put(AOI_GEOMETRY, geometry );
                            } catch (ParseException e) {
                                // no can do!
                            }
                        }
View Full Code Here

TOP

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

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.