Examples of ShapefileDataStore


Examples of org.geotools.data.shapefile.ShapefileDataStore

  @Before
  public void setUp() throws Exception {
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    URL url = classloader.getResource(SHAPE_FILE);
    DataStore dataStore = new ShapefileDataStore(url);
    featureModel = new ShapeInMemFeatureModel(dataStore, LAYER_NAME, 4326, converterService);
    featureModel.setLayerInfo(layerInfo);

    FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource();
    FeatureIterator<SimpleFeature> fi = fs.getFeatures().features();
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

  @Before
  public void init() throws Exception {
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    URL url = classloader.getResource(SHAPE_FILE);
    DataStore dataStore = new ShapefileDataStore(url);
    featureModel = new GeoToolsFeatureModel(dataStore, LAYER_NAME, 4326, converterService);
    featureModel.setLayerInfo(layerInfo);

    FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource();
    FeatureIterator<SimpleFeature> fi = fs.getFeatures().features();
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

     
      Map<String, Serializable> params = new HashMap<String, Serializable>();
      params.put("url", outputShapefile.toURI().toURL());
      params.put("create spatial index", Boolean.TRUE);
     
      ShapefileDataStore dataStore = (ShapefileDataStore)dataStoreFactory.createNewDataStore(params);
      dataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);

          SimpleFeatureType STOP_TYPE = DataUtilities.createType(
                    "Stop",                
                    "location:Point:srid=4326," +
                    "name:String," +
                    "code:String," +
                    "desc:String," +
                    "id:String," +
                    "agency:String"    
            );
         
          SimpleFeatureType ROUTE_TYPE = DataUtilities.createType(
                    "Route",                   // <- the name for our feature type
                    "route:LineString:srid=4326," +
                    "patternName:String," +
                    "shortName:String," +
                    "longName:String," +
                    "desc:String," +
                    "type:String," +
                    "url:String," +
                    "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.");

            Transaction transaction = new DefaultTransaction("create");

            String typeName = dataStore.getTypeNames()[0];
            SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);

            if (featureSource instanceof SimpleFeatureStore)
            {
                SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

        ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", outputShapeFile.toURI().toURL());
        params.put("create spatial index", Boolean.TRUE);
        ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
        dStore.createSchema(featureType);
        dStore.forceSchemaCRS(mapCrs);

        JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

        JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputShapeFile.getAbsolutePath(), true, true,
                new NullProgressMonitor());
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

            ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put("url", outputLinesShapeFile.toURI().toURL());
            params.put("create spatial index", Boolean.TRUE);
            ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
            dStore.createSchema(featureType);
            dStore.forceSchemaCRS(mapCrs);

            JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

            JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputLinesShapeFile.getAbsolutePath(), true, true,
                    new NullProgressMonitor());

        } catch (Exception e1) {
            JGrassToolsPlugin.log(e1.getLocalizedMessage(), e1);
            e1.printStackTrace();
        }
        /*
         * create the points shapefile
         */

        File outputPointsShapeFile = new File(outputFolderFile, "gpspoints.shp");

        b = new SimpleFeatureTypeBuilder();
        b.setName("geopaparazzinotes");
        b.setCRS(mapCrs);
        b.add("the_geom", Point.class);
        b.add("ALTIMETRY", String.class);
        b.add("DATE", String.class);
        featureType = b.buildFeatureType();

        try {
            MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, mapCrs);

            pm.beginTask("Import gps to points...", logsList.size());
            DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
            int index = 0;
            for( GpsLog log : logsList ) {
                List<GpsPoint> gpsPointList = log.points;
                for( GpsPoint gpsPoint : gpsPointList ) {
                    Coordinate c = new Coordinate(gpsPoint.lon, gpsPoint.lat);
                    Point point = gF.createPoint(c);

                    Point reprojectPoint = (Point) JTS.transform(point, transform);
                    Object[] values = new Object[]{reprojectPoint, String.valueOf(gpsPoint.altim), gpsPoint.utctime};

                    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
                    builder.addAll(values);
                    SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + index++);
                    newCollection.add(feature);
                }
                pm.worked(1);
            }
            pm.done();

            ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put("url", outputPointsShapeFile.toURI().toURL());
            params.put("create spatial index", Boolean.TRUE);
            ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
            dStore.createSchema(featureType);
            dStore.forceSchemaCRS(mapCrs);

            JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

            JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputPointsShapeFile.getAbsolutePath(), true, true,
                    new NullProgressMonitor());
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

            ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put("url", outputPointsShapeFile.toURI().toURL());
            params.put("create spatial index", Boolean.TRUE);
            ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
            dStore.createSchema(featureType);
            dStore.forceSchemaCRS(mapCrs);

            JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

            JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputPointsShapeFile.getAbsolutePath(), true, true,
                    new NullProgressMonitor());
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

        // creates the shapefile
        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", URLUtils.fileToURL(file)); //$NON-NLS-1$
        params.put("create spatial index", Boolean.TRUE); //$NON-NLS-1$
        ShapefileDataStore ds = (ShapefileDataStore) dataStoreFactory.createDataStore(params);
        ds.createSchema(type);
       
        SimpleFeatureStore featureSource = (SimpleFeatureStore) ds.getFeatureSource();
        List<FeatureId> ids = featureSource.addFeatures(fc);
        return ids.size() >= 0;
    }
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

   
    // create and write the new shapefile   
    ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
    Map params = new HashMap();
    params.put( "url", file.toURL() );
    ShapefileDataStore dataStore =
        (ShapefileDataStore) factory.createNewDataStore( params );   
    dataStore.createSchema( featureType );
   
    FeatureStore store = (FeatureStore) dataStore.getFeatureSource();
    store.addFeatures( source.getFeatures() );
    dataStore.forceSchemaCRS( crs );
}
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

              ICatalog catalog = CatalogPlugin.getDefault()
                  .getLocalCatalog();
              List<IResolve> members = catalog
                  .members(new NullProgressMonitor());
              for (IResolve resolve : members) {
                ShapefileDataStore store = resolve.resolve(
                    ShapefileDataStore.class,
                    new NullProgressMonitor());
                if (store != null) {
                  if (ds.getSchema().getTypeName().equals(
                      store.getSchema().getTypeName())) {
                    ShpServiceExtension fac = new ShpServiceExtension();
                    Map<String, Serializable> params = fac
                        .createParams(resolve
                            .getIdentifier());
                    IService replacement = fac
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

    /*
     * @see org.locationtech.udig.catalog.IService#getInfo(org.eclipse.core.runtime.IProgressMonitor)
     */
    protected IServiceInfo createInfo( IProgressMonitor monitor ) throws IOException {
        ShapefileDataStore dataStore = getDS(monitor); // load ds
        if (dataStore == null) {
            return null; // could not connect
        }
        rLock.lock();
        try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.