Package org.geotools.data.simple

Examples of org.geotools.data.simple.SimpleFeatureCollection


              GisUploadField.delete("gisUpload = ?", gisUpload);
             
              FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile);
              SimpleFeatureSource featureSource = store.getFeatureSource();
             
              SimpleFeatureCollection featureCollection = featureSource.getFeatures();
              SimpleFeatureIterator featureIterator = featureCollection.features();
             
              List<AttributeDescriptor> attributeDescriptors = featureSource.getSchema().getAttributeDescriptors();
             
              // update field listing
              Long position = new Long(0);
View Full Code Here


                    "routeColor:String," +
                    "routeTextColor:String," +
                    "agency:String"    
            );
         
          SimpleFeatureCollection collection = FeatureCollections.newCollection();

            SimpleFeatureBuilder featureBuilder = null;
           
            if(gisExport.type.equals(GisUploadType.STOPS))
            {
              dataStore.createSchema(STOP_TYPE);
              featureBuilder = new SimpleFeatureBuilder(STOP_TYPE);
             
              List<Stop> stops = Stop.find("agency in (:ids)").bind("ids", gisExport.agencies).fetch();
             
              for(Stop s : stops)
              {
                featureBuilder.add(s.locationPoint());
                    featureBuilder.add(s.stopName);
                    featureBuilder.add(s.stopCode);
                    featureBuilder.add(s.stopDesc);
                    featureBuilder.add(s.gtfsStopId);
                    featureBuilder.add(s.agency.name);
                    SimpleFeature feature = featureBuilder.buildFeature(null);
                    collection.add(feature)
              }
            }
            else if(gisExport.type.equals(GisUploadType.ROUTES))
            {
              dataStore.createSchema(ROUTE_TYPE);
              featureBuilder = new SimpleFeatureBuilder(ROUTE_TYPE);
             
                List<Route> routes = Route.find("agency in (:ids)").bind("ids", gisExport.agencies).fetch();
             
                // check for duplicates

                // HashMap<String, Boolean> existingRoutes = new HashMap<String,Boolean>();
               
              for(Route r : routes)
              {
//                String routeId = r.routeLongName + "_" + r.routeDesc + "_ " + r.phone.id;
//               
//                if(existingRoutes.containsKey(routeId))
//                  continue;
//                else
//                  existingRoutes.put(routeId, true);
               
               
                List<TripPattern> patterns = TripPattern.find("route = ?", r).fetch();
                for(TripPattern tp : patterns)
                  {
                  if(tp.shape == null)
                    continue;
               
                  featureBuilder.add(tp.shape.shape);
                  featureBuilder.add(tp.name);
                  featureBuilder.add(r.routeShortName);
                      featureBuilder.add(r.routeLongName);
                      featureBuilder.add(r.routeDesc);
                     
                      if(r.routeType != null)
                        featureBuilder.add(r.routeType.toString());
                      else
                        featureBuilder.add("");
                     
                      featureBuilder.add(r.routeUrl);
                      featureBuilder.add(r.routeColor);
                      featureBuilder.add(r.routeTextColor);
                      featureBuilder.add(r.agency.name);
                      SimpleFeature feature = featureBuilder.buildFeature(null);
                      collection.add(feature)
                  }
              }
            }
            else
              throw new Exception("Unknown export type.");
View Full Code Here

        }
        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 {
View Full Code Here

                @SuppressWarnings("unchecked")
                public void run(IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
                    monitor.beginTask(Messages.ArrowSelection_0, 5);
                    ReferencedEnvelope bbox = getContext().getBoundingBox(new Point(x, y), 5);
                    SimpleFeatureCollection collection = null;
                    FeatureIterator<SimpleFeature> iter = null;
                    try {
                        ILayer selectedLayer = getContext().getSelectedLayer();
                        SimpleFeatureSource source = selectedLayer.getResource(
                                SimpleFeatureSource.class, new SubProgressMonitor(monitor, 1));
                        if (source == null)
                            return;
                        collection = source.getFeatures(selectedLayer.createBBoxFilter(bbox,
                                new SubProgressMonitor(monitor, 1)));
                        iter = collection.features();
                        if (!iter.hasNext()) {
                            if (!e.buttonsDown()) {
                                getContext().sendASyncCommand(
                                        getContext().getEditFactory()
                                                .createNullEditFeatureCommand());
View Full Code Here

                new SubProgressMonitor(new NullProgressMonitor(), 1));
        if (featureSource == null) {
            noProperLayerSelected();
            return;
        }
        SimpleFeatureCollection featureCollection = featureSource.getFeatures();
        crs = featureCollection.getSchema().getCoordinateReferenceSystem();
        featureList = featureCollectionToList(featureCollection);
        previousLayerName = selectedLayer.getName();
        index = 0;
    }
View Full Code Here

        if (filter != null) {
            try {
                if (geoResource.canResolve(SimpleFeatureStore.class)) {
                    final SimpleFeatureStore featureSource = geoResource.resolve(SimpleFeatureStore.class,
                            new NullProgressMonitor());
                    final SimpleFeatureCollection featureCollection = featureSource.getFeatures(filter);
                    final SimpleFeatureIterator featureIterator = featureCollection.features();
                    try {
                         if (featureIterator.hasNext()) {
                             return featureIterator.next();
                         }
                    } finally {
View Full Code Here

        boolean crsEqual = CRS.equalsIgnoreMetadata(featureCrs, mapCrs);
        MathTransform mathTransform = CRS.findMathTransform(featureCrs, mapCrs, true);
       
        String name = geometryDescriptor.getLocalName();
        Filter bboxFilter = getBboxFilter(name, tBounds);
        SimpleFeatureCollection featureCollection = featureSource.getFeatures(bboxFilter);

        FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
        IViewportModel viewPort = ApplicationGIS.getActiveMap().getViewportModel();
        List<AbstractDrawCommand> commands = new ArrayList<AbstractDrawCommand>();
        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
            Geometry fGeom = (Geometry) feature.getDefaultGeometry();
View Full Code Here

        SimpleFeatureSource featureSource = (SimpleFeatureSource) selectedLayer.getResource(FeatureSource.class,
                new SubProgressMonitor(monitor, 1));
        if (featureSource == null) {
            return;
        }
        SimpleFeatureCollection featureCollection = featureSource.getFeatures(selectedLayer.getQuery(true));
        SimpleFeatureIterator featureIterator = featureCollection.features();
        EditCommandFactory cmdFactory = EditCommandFactory.getInstance();
        List<UndoableMapCommand> cmdList = new LinkedList<UndoableMapCommand>();
        count = 0;
        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
View Full Code Here

             * @param id
             * @return True if the feature is in the store.
             */
            private boolean isFeatureOnStore( Filter id ) {

                SimpleFeatureCollection collection = null;
                SimpleFeatureIterator iter = null;
                try {
                    collection = layerList.get(0).getResource(SimpleFeatureSource.class, null).getFeatures(id);
                    iter = collection.features();
                    if (iter.hasNext()) {
                        return true;
                    }
                } catch (IOException e) {
                    e.printStackTrace();
View Full Code Here

                    Messages.getString("OperationUtils_warning"), Messages.getString("OperationUtils_sametypeproblem"), //$NON-NLS-1$ //$NON-NLS-2$
                    MSGTYPE.WARNING);
            return;
        }

        SimpleFeatureCollection featureCollection = featureSource.getFeatures(selectedLayer.getQuery(true));
        if (featureCollection.size() < 1) {
            showMessage(
                    display,
                    Messages.getString("OperationUtils_warning"), Messages.getString("OperationUtils_nofeaturesproblem"), MSGTYPE.WARNING); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }

        SimpleFeatureIterator featureIterator = featureCollection.features();
        EditCommandFactory cmdFactory = EditCommandFactory.getInstance();
        List<UndoableMapCommand> copyOverList = new LinkedList<UndoableMapCommand>();
        List<UndoableMapCommand> deleteOldList = new LinkedList<UndoableMapCommand>();
        int count = 0;
        while( featureIterator.hasNext() ) {
View Full Code Here

TOP

Related Classes of org.geotools.data.simple.SimpleFeatureCollection

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.