Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.ICatalog


        progressMonitor.beginTask("task", 6); //$NON-NLS-1$
        progressMonitor.worked(1);

        try {

            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();

            // first search the local catalog.
            List<IResolve> matches = catalog.find(url, new SubProgressMonitor(progressMonitor, 2));

            for (IResolve resolve : matches) {
                if (resolve instanceof ExpectedService) {
                    // found the resource now we have to search it for the
                    // resource we want
                    if (searchServiceForResource(new SubProgressMonitor(progressMonitor, 2), addPosition, map,
                            (IService) resolve))
                        return;
                } else if (resolve instanceof ExpectedGeoResource) {
                    // yay we found the resource this is too easy:)

                    ApplicationGIS.addLayersToMap(map, Collections.singletonList((IGeoResource) resolve), addPosition);
                    return;
                }
            }

            // usually only returns 1 service but it may be that multiple
            // Services know how to interpret the URL
            List<IService> services = CatalogPlugin.getDefault().getServiceFactory().createService(url);
            IService found = null;
            progressMonitor.worked(1);

            // find the service you want
            for (IService service : services) {
                // determine if the service is the type you are expecting;
                if (service instanceof ExpectedService) {
                    found = service;
                    break;
                }
            }

            catalog.add(found);
            searchServiceForResource(new SubProgressMonitor(progressMonitor, 2), addPosition, map, found);

        } finally {
            progressMonitor.done();
        }
View Full Code Here


  boolean done;
 
  @Before
  public void setUp() throws Exception {
    //get a georesource
    ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
    IServiceFactory sFactory
      = CatalogPlugin.getDefault().getServiceFactory();
   
    HashMap params = new HashMap();
    params.put("dummy", DummyService.url);
View Full Code Here

       
        //ensure the right type of service was created
        IService service = services.get(0);
        assertNotNull( service );
       
        ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
        catalog.add( service ); // we can now find this service!
       
        List<IResolve> found = catalog.search("csv",null, null );
        assertEquals( 2, found.size() );
       
        //get all the resources from the service
        List<? extends IGeoResource> resources = service.resources(null);
        assertNotNull(resources);
View Full Code Here

     * @param location represents the location the mapgraphic will sit on the map   *
   */
  private static Layer createWhitebox(Map map, Rectangle location) {
      try {

          ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();

            LayerFactory layerFactory = map.getLayerFactory();
            URL resourceID = new URL(null, "mapgraphic://localhost/mapgraphic#org.locationtech.udig.tutorial.mapgraphic.Whitebox", CorePlugin.RELAXED_HANDLER); //$NON-NLS-1$
            ID id = new ID(resourceID);
            IGeoResource resource = localCatalog.getById(IGeoResource.class, id, new NullProgressMonitor());
            Layer whiteboxLayer = layerFactory.createLayer(resource);
           
            whiteboxLayer.getStyleBlackboard().put(LocationStyleContent.ID, location);
            return whiteboxLayer;
      }
View Full Code Here

     * @param location represents the location the mapgraphic will sit on the map
     */
    protected static Layer createTitleArea(Map map, Rectangle location, IProgressMonitor monitor) {
        try {

            ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
            List<Layer> layersInternal = map.getLayersInternal();
            LayerFactory layerFactory = map.getLayerFactory();
           
            Iterator layerIterator = layersInternal.iterator();
            Layer farmParcelLayer = null;
            while (layerIterator.hasNext()) {
                Layer layer = (Layer)layerIterator.next();
                if (layer.getName().equals("SDE.DATE_PRIMARE")) {
                    farmParcelLayer = layer;
                }
            }
           
            if (farmParcelLayer == null) {
                throw new IllegalStateException("cannot find farm layer");
            }
           

            //get title from selected feature of farm layer           
            Filter farmParcelFilter = farmParcelLayer.getFilter();
            Query query = new DefaultQuery(farmParcelLayer.getSchema().getTypeName(),
                                           farmParcelFilter,
                                           new String[0]  ); //{"nume_com", "fbid"}
           
             FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
                farmParcelLayer.getResource(FeatureSource.class,
                                            new SubProgressMonitor(monitor, 1));
            FeatureCollection<SimpleFeatureType, SimpleFeature>  features = featureSource.getFeatures(query);
            FeatureIterator<SimpleFeature> featureIterator = features.features();
            if (!featureIterator.hasNext()) {
                throw new IllegalStateException("At least one feature must be selected in the farm layer. "+features.size()+ " found.");
            }
            SimpleFeature selectedFarmFeature = featureIterator.next();
            String prov = (String)selectedFarmFeature.getAttribute(0);
            String id = (String)selectedFarmFeature.getAttribute(1);
           
            //put layer info on the mapgraphic's style blackboard
            URL detailsResId = new URL(null, "mapgraphic://localhost/mapgraphic#org.locationtech.udig.tutorial.mapgraphic.TitleArea", CorePlugin.RELAXED_HANDLER);
            IGeoResource detailsRes = localCatalog.getById(IGeoResource.class, new ID(detailsResId), new NullProgressMonitor());
            
            Layer titleAreaLayer = layerFactory.createLayer(detailsRes);
            titleAreaLayer.getStyleBlackboard().put(LocationStyleContent.ID, location);
            XMLMemento selectedFeatureMemento = XMLMemento.createWriteRoot("style");
            selectedFeatureMemento.putString(FEATURE_ID_KEY, id);
View Full Code Here

     */
  private void addToCatalog(File destination) throws MalformedURLException {
    IServiceFactory serviceFactory = CatalogPlugin.getDefault().getServiceFactory();
    URL url = DataUtilities.fileToURL( destination );
        List<IService> services = serviceFactory.createService(url);
    ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();;
    for (IService service : services) {
      localCatalog.add(service);
    }
  }
View Full Code Here

                graphLayer = look;
                break;
            }
        }
        if( graphLayer == null ){           
            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
            IGeoResource resource = catalog.getById(IGeoResource.class, GRAPH_ID, new NullProgressMonitor() );
            if( resource == null ){
                return; // not available?
            }
            List<IGeoResource> resourceList = Collections.singletonList( resource );           
            List< ? extends ILayer> added = ApplicationGIS.addLayersToMap(map, resourceList, 0 );
            if( added.isEmpty() ){
                return; // not available?
            }
            graphLayer = (ILayer) added.get(0);           
        }
        if( !graphLayer.isVisible() ){
            map.sendCommandASync( new SetLayerVisibilityCommand(graphLayer, true) );
        }
       
        for( ILayer look : map.getMapLayers() ){
            URL id = look.getGeoResource().getIdentifier();
            if(PATH_ID.equals(id) ){
                pathLayer = look;
                break;
            }
        }
        if( pathLayer == null ){           
            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
            IGeoResource resource = catalog.getById(IGeoResource.class, PATH_ID, new NullProgressMonitor() );
            if( resource == null ){
                return; // not available?
            }
            List<IGeoResource> resourceList = Collections.singletonList( resource );           
            List< ? extends ILayer> added = ApplicationGIS.addLayersToMap(map, resourceList, 0 );
View Full Code Here

         * @param arg0 the input data
         * @return Object[]
         */
        public Object[] getElements( Object arg0 ) {
            // add the service to the catalog
            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
            try {
                ArrayList<IResolve> finalCatalogMembers = new ArrayList<IResolve>();
                List< ? extends IResolve> allCatalogMembers = catalog.members(null);
                for( IResolve resolve : allCatalogMembers ) {
                    if (resolve instanceof JGrassService) {
                        finalCatalogMembers.add(resolve);
                    }
                }
View Full Code Here

        if (service == null) {
            return null;
        }
        // check that the service is part of catalog... If not add
        ICatalog local = CatalogPlugin.getDefault().getLocalCatalog();
        if (local.getById(IService.class, service.getID(), new NullProgressMonitor()) == null) {
            local.add(resource.service(null));
        }

        LayerImpl layer = (LayerImpl) ProjectFactory.eINSTANCE.createLayer();

        if (layer == null) {
            throw new IOException(
                    "Unable to create layer from resource '" + resource.getIdentifier() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        ID resourceID = resource.getID();
        layer.setResourceID(resourceID);

        // process the style content extension point to initially populate
        // the style blackboard with style info
        // TODO: the style objects need access to preference system
        final Layer theLayer = layer;

        ICatalog localCatalog = local;
        ID layerResourceID = layer.getResourceID();
        IProgressMonitor monitor = ProgressManager.instance().get();
        List<IResolve> resolves = localCatalog.find(layerResourceID, monitor);
        if (resolves.isEmpty()) {
            // Identifier lookup is being inconsistent; this often happens when code trips up over
            // converting URLs to and from Files
            throw new IOException("Could not find " + layerResourceID + " in local catalog");
        }
View Full Code Here

            IResolve resolve = mapsetMembers.get(i);
            URL identifier = resolve.getIdentifier();
            if (mapsetIdentifier.toExternalForm().equals(identifier.toExternalForm())) {
                mapsetMembers.remove(i);

                ICatalog catalog = parent(null);
                if (catalog instanceof CatalogImpl) {
                    IResolveDelta delta = new ResolveDelta(resource, Kind.REMOVED);
                    IResolveChangeEvent event = new ResolveChangeEvent(this, Type.POST_CHANGE, delta);
                    ((CatalogImpl) catalog).fire(event);
                }
View Full Code Here

TOP

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

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.