Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IGeoResource


                        IMap activeMap = ApplicationGIS.getActiveMap();
                        int layerNum = activeMap.getMapLayers().size();
                        List<IResolve> members = service.members(progressMonitor);
                        for( IResolve iRes : members ) {
                            if (iRes.canResolve(IGeoResource.class)) {
                                IGeoResource geoResource = iRes.resolve(IGeoResource.class, progressMonitor);
                                ApplicationGIS.addLayersToMap(null, Collections.singletonList(geoResource), layerNum);
                            }
                        }
                    }
                }
View Full Code Here


                                    newCollection.add(feature);
                                    pm.worked(1);
                                }
                                pm.done();

                                IGeoResource resource = CatalogPlugin.getDefault().getLocalCatalog()
                                        .createTemporaryResource(type);

                                resource.resolve(FeatureStore.class, pm).addFeatures(newCollection);
                                ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(), Collections.singletonList(resource),
                                        -1);
                            } catch (Exception e) {
                                e.printStackTrace();
                                String message = "An error occurred while loading the places to map";
View Full Code Here

         */
        IRunnableWithProgress operation = new IRunnableWithProgress(){

            public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException {

                IGeoResource geoResource = mainPage.getGeoResource();
                String folderPath = mainPage.getFolderPath();
                String fileName = mainPage.getFileName();
                String newPath = folderPath + File.separator + fileName;
                CoordinateReferenceSystem fileCrs = mainPage.getFileCrs();
                CoordinateReferenceSystem newCrs = mainPage.getNewCrs();
                boolean isAscii = mainPage.isAscii();
                boolean isTiff = mainPage.isTiff();

                /*
                 * finally do some processing
                 */
                pm.beginTask("Exporting map...", IProgressMonitor.UNKNOWN);
                try {
                    // TODO reactivate this as soon as netcdfs are back
                    // if (geoResource.canResolve(NetcdfMapGeoResource.class)) {
                    // NetcdfMapGeoResource netcdfGeoResource =
                    // geoResource.resolve(NetcdfMapGeoResource.class, pm);
                    // List<DateTime> availableTimeSteps =
                    // netcdfGeoResource.getAvailableTimeSteps();
                    // double[] availableElevationLevels =
                    // netcdfGeoResource.getAvailableElevationLevels();
                    //
                    // if (availableTimeSteps.size() == 0) {
                    // availableTimeSteps = new ArrayList<DateTime>();
                    // // add a dummy one to make sure it enters the loop
                    // availableTimeSteps.add(null);
                    // }
                    // if (availableElevationLevels == null || availableElevationLevels.length == 0)
                    // {
                    // availableElevationLevels = new double[1];
                    // // add a dummy one to make sure it enters the loop
                    // availableElevationLevels[0] = Double.NaN;
                    // }
                    //
                    // for( DateTime dateTime : availableTimeSteps ) {
                    // for( double currentElevationDouble : availableElevationLevels ) {
                    // CoverageReadRequest readRequest = new DefaultCoverageReadRequest();
                    //
                    // if (dateTime != null) {
                    // SortedSet<TemporalGeometricPrimitive> temporalSubset = new
                    // TreeSet<TemporalGeometricPrimitive>();
                    // temporalSubset.add(new DefaultInstant(new
                    // DefaultPosition(dateTime.toDate())));
                    // readRequest.setTemporalSubset(temporalSubset);
                    // }
                    // if (!Double.isNaN(currentElevationDouble)) {
                    // Set<NumberRange<Double>> verticalSubset = new TreeSet<NumberRange<Double>>();
                    // NumberRange<Double> vertical = new NumberRange<Double>(Double.class,
                    // currentElevationDouble,
                    // true, currentElevationDouble, true);
                    // verticalSubset.add(vertical);
                    // readRequest.setVerticalSubset(verticalSubset);
                    // }
                    //
                    // GridCoverage2D coverage2D = netcdfGeoResource.getGridCoverage(readRequest);
                    //
                    // StringBuilder sB = new StringBuilder(newPath);
                    // if (dateTime != null) {
                    // sB.append("_");
                    // sB.append(dateTime.toString(dateTimeFormatter));
                    // }
                    // if (!Double.isNaN(currentElevationDouble)) {
                    // sB.append("_");
                    // sB.append(currentElevationDouble);
                    // }
                    // String mapPath = sB.toString();
                    // pm.subTask("Exporting map: " + mapPath);
                    // dumpMap(coverage2D, fileCrs, newCrs, mapPath, isAscii, isTiff);
                    // }
                    // }
                    //
                    // } else
                    if (geoResource.canResolve(GridCoverage.class)) {
                        GridCoverage2D coverage2D = (GridCoverage2D) geoResource.resolve(GridCoverage.class, pm);
                        dumpMap(coverage2D, fileCrs, newCrs, newPath, isAscii, isTiff);
                    } else {
                        throw new IOException("The selected resource doesn't seem to be a coverage layer: " + geoResource.getTitle());
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    String message = "An error occurred while exporting the resource: " + geoResource.getTitle();
                    ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassToolsPlugin.PLUGIN_ID, e);
                }
                pm.done();

            }
View Full Code Here

       
    }
   
    private void setPageInputAndEnablements() {
        final IProgressMonitor monitor = new NullProgressMonitor();
        final IGeoResource resource = (IGeoResource) getElement().getAdapter(IGeoResource.class);
        setShpPropertyParser(resource);
        setResourcePropsEnablements(resource, monitor);
        setFeaturePropsEnablements(resource, monitor);
        setHotlinkDescriptorParser(resource);
        setHotlinkPropsEnablements(resource, monitor);
View Full Code Here

    writer.write(warpedCoverage.view(ViewType.GEOPHYSICS), null);

    // add the result as a layer to the map by
    // loading that file as a layer
    File tempfile = new File(filename);
    IGeoResource tiffResource = null;
    try {
      writer = new GeoTiffWriter(tempfile);
      writer.write(warpedCoverage.view(ViewType.GEOPHYSICS), null);
      // tiffResource = getTiffResource(tempfile.toURL());
      tiffResource = getTiffResource(tempfile.toURI().toURL());
View Full Code Here

    if (services.isEmpty()) {
      return null;
    }
    for (IService service : services) {
      IResolve resolve;
      IGeoResource geoR;
      try {
        resolve = service.members(null).get(0);
        geoR = resolve.resolve(IGeoResource.class, new NullProgressMonitor());
        return geoR;
      } catch (IOException e) {
View Full Code Here

          .find(MapGraphicService.SERVICE_URL, null);
    List<IResolve> members = new ArrayList<IResolve>();
    members = mapgraphics.get(0).members(null);
    assert members != null;

    IGeoResource resolved = null;
    for (IResolve resolve : members) {

      if (resolve.canResolve(MapMarksGraphics.class)) {
        resolved = resolve.resolve(IGeoResource.class, null);
        break;
      }
    }
    assert resolved != null;
    ApplicationGIS.addLayersToMap(map, Collections.singletonList(resolved), -1);

    // Get the newly added mapgraphic layer, add the current images to
    // it,
    // and store it
    List<ILayer> mapLayers = map.getMapLayers();
    Iterator<ILayer> iterator = mapLayers.iterator();
    while (iterator.hasNext()) {
      ILayer layer = iterator.next();
      IGeoResource geoResource = layer.findGeoResource(MapMarksGraphics.class);
      if (geoResource != null) {
        MapMarksGraphics mapGraphic = geoResource.resolve(MapMarksGraphics.class, null);
        this.mapMarkGraphic = mapGraphic;
        this.mapGraphicLayer = layer;
        break;
      }
    }
View Full Code Here

    // remove the mapgraphic layer from the map
    List<ILayer> mapLayers = map.getMapLayers();
    Iterator<ILayer> iterator = mapLayers.iterator();
    while (iterator.hasNext()) {
      ILayer layer = iterator.next();
      IGeoResource geoResource = layer.findGeoResource(MapMarksGraphics.class);
      if (geoResource != null) {
        map.sendCommandASync(new DeleteLayerCommand((Layer) layer));
        break;
      }
    }
View Full Code Here

         * @return feature label
         */
        private String getFeatureLabel(AdaptableFeature feature) {
           
            final ILayer layer = (ILayer) feature.getAdapter(ILayer.class);
            final IGeoResource resource = layer.getGeoResource();
           
            return getFeatureLabel(resource, feature);
           
        }
View Full Code Here

                icon = (ImageDescriptor) layer.getProperties().get("generated icon");
                if( icon == null ){
                    icon = layer.getIcon();
                }
                if( icon == null ){
                    IGeoResource resource = layer.getGeoResource();
                    try {
                        icon = resource.getInfo(null).getImageDescriptor();
                    } catch (IOException e) {
                        // not expecting this to block or throw IO as the layer was available
                        // to be hit by the info tool
                    }                   
                }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.catalog.IGeoResource

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.