Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IGeoResource


    @Override
    public <T> T adapt(IResolve resolve, Class<T> adapter, IProgressMonitor monitor)
            throws IOException {
        if (resolve instanceof IGeoResource) {
            final IGeoResource resource = (IGeoResource) resolve;
            if (adapter.isAssignableFrom(IHotlinkSource.class)) {
                final IHotlinkSource source = new BasicHotlinkSource(resource);
                return adapter.cast(source);
            }   
        }
View Full Code Here


                    }
                    LabelData data = new LabelData();
                    try {
                        if(text){
                          if(element instanceof IGeoResource) {
                            IGeoResource resource = (IGeoResource) element;
                            data.text = resource.getInfo(monitor).getTitle();
                            IService service = resource.service(monitor);
                            if( service != null ){
                                service.getPersistentProperties().put(resource.getID() + "_title", data.text);
                            }
                          } else if(element instanceof IService) {
                            IService service = (IService) element;
                            IServiceInfo info = service.getInfo(monitor);
                            if( info != null ){
View Full Code Here

         */
        IRunnableWithProgress operation = new IRunnableWithProgress(){

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

                IGeoResource geoResource = mainPage.getGeoResource();
                String filePath = mainPage.getFilePath();

                /*
                 * finally do some processing
                 */
                pm.beginTask(Messages.getString("KmlExportWizard.taskExportingMap"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
                try {
                    if (geoResource.canResolve(SimpleFeatureSource.class)) {

                        SimpleFeatureSource featureStore = (SimpleFeatureSource) geoResource.resolve(SimpleFeatureSource.class,
                                pm);
                        KmlUtils.writeKml(new File(filePath), featureStore.getFeatures());
                    } else {
                        throw new IOException(Messages.getString("KmlExportWizard.error.ResourceIsNotAFeatureLayer") + geoResource.getTitle()); //$NON-NLS-1$
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    String message = Messages.getString("KmlExportWizard.error.ErrorOccuredWhileExproting") + geoResource.getTitle(); //$NON-NLS-1$
                    ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, KmlToolPlugin.PLUGIN_ID, e);
                }
                pm.done();

            }
View Full Code Here

            public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException {
                try {
                    FeatureCollection<SimpleFeatureType, SimpleFeature> collection = KmlUtils.kmlFile2FeatureCollection(kmlFile);

                    IGeoResource resource = CatalogPlugin.getDefault().getLocalCatalog()
                            .createTemporaryResource(collection.getSchema());

                    @SuppressWarnings("unchecked")
                    FeatureStore<SimpleFeatureType, SimpleFeature> store = resource.resolve(FeatureStore.class, pm);
                    store.addFeatures(collection);

                    ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(), Collections.singletonList(resource), -1);
                } catch (Exception e) {
                    e.printStackTrace();
View Full Code Here

    /**
     * @see org.locationtech.udig.project.render.IRenderMetricsFactory#canRender(org.locationtech.udig.project.render.IRenderContext)
     */
    public boolean canRender( IRenderContext context ) {
        IGeoResource geoResource = context.getGeoResource();
        if (geoResource.canResolve(AbstractGridCoverage2DReader.class)) {
            return false; // give image moasic priority over shapefile
        }
        return context.getGeoResource().canResolve(FeatureSource.class);
    }
View Full Code Here

     *
     * @param layer
     */
    public void setLayer( Layer layer ) {
        this.layer = layer;
        IGeoResource resource = layer.getGeoResource();
        mapsetPathAndMapName = JGrassCatalogUtilities.getMapsetpathAndMapnameFromJGrassMapGeoResource(resource);
        colrFile = new File(mapsetPathAndMapName[0] + File.separator + JGrassConstants.COLR + File.separator
                + mapsetPathAndMapName[1]);
    }
View Full Code Here

                        Object data = event.data;
                        if (data instanceof TreeSelection) {
                            TreeSelection selection = (TreeSelection) data;
                            Object firstElement = selection.getFirstElement();

                            IGeoResource geoResource = null;
                            if (firstElement instanceof LayerImpl) {
                                LayerImpl layer = (LayerImpl) firstElement;
                                geoResource = layer.getGeoResource();

                            }
                            if (firstElement instanceof IService) {
                                IService service = (IService) firstElement;
                                List< ? extends IGeoResource> resources = service.resources(new NullProgressMonitor());
                                if (resources.size() > 0) {
                                    geoResource = resources.get(0);
                                }
                            }
                            if (geoResource != null) {
                                ID id = geoResource.getID();
                                if (id != null)
                                    if (id.isFile()) {
                                        File file = id.toFile();
                                        if (file.exists()) {
                                            setTextContent(file);
View Full Code Here

            // default to current project
            owner = ProjectPlugin.getPlugin().getProjectRegistry().getCurrentProject();
        }
        if (name == null) {
            if (resources.size() > 0) {
                IGeoResource resource = resources.get(0);
                String title = resource.getTitle();
                if( title == null || title.trim().length() == 0 ){
                    IGeoResourceInfo info = resource.getInfo(monitor);
                    if (info != null) {
                        title = info.getTitle();
                    }
                }
                if (title != null && !title.contains("(") ){
                    name = title;
                }
                if( name == null ){
                    name = resource.getID().toBaseFile();
                }               
            }
           
            if (name == null) {
                name = Messages.CreateMapCommand_defaultname;
View Full Code Here

     */
    public List<Object> getCheckedElements() {
        List<Object> list = new ArrayList<Object>();
        for( Object object : viewer.getCheckedElements() ) {
            if (object instanceof IGeoResource) {
                IGeoResource resource = (IGeoResource) object;
                list.add(resource);
            }
        }
        return list;
    }
View Full Code Here

           
            if (resources != null) {
                Set<IService> expanded=new HashSet<IService>();
                for( Map.Entry<IGeoResource, IService> entry:resources.entrySet() ) {
                    checked++;
                    IGeoResource resource = entry.getKey();
                    IService service = entry.getValue();
                   
                    viewer.setChecked(resource, true);
                    viewer.setChecked(service, true);
                    expanded.add(service);
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.