private MathTransform createMathTransform(ILayer sourceLayer, ILayer targetLayer) { MathTransform temp; try { CoordinateReferenceSystem targetCRS = targetLayer.getCRS(); CoordinateReferenceSystem sourceCRS = sourceLayer.getCRS(); if (targetCRS.equals(sourceCRS)) temp = null; else temp = CRS.findMathTransform(sourceCRS, targetCRS, true); if (temp == null || temp.isIdentity()) temp = null; } catch (FactoryException e1) { ProjectPlugin.log("", e1); // $NON-NLS-1$ temp = null; } if (temp == null) { try { return CRS.findMathTransform(DefaultGeographicCRS.WGS84, DefaultGeographicCRS.WGS84); } catch (Exception e) { ProjectPlugin.log("", e); // $NON-NLS-1$ return null; } } return temp; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NO MORE */ public IGenericProjectElement createIGenericProjectElementFromString( EDataType eDataType, String initialValue) { try { UdigMemento memento = UdigMemento.readString(initialValue); IGenericProjectElement backingObject = createGenericProjectElement( IGenericProjectElement.class, memento.getString(EXTENSION_POINT_ID_KEY)); backingObject.init(memento); return backingObject; } catch (IOException e) { ProjectPlugin.log("Error parsing memento data for IGenericProject Element", e); // $NON-NLS-1$ return null; } }
/** @see net.refractions.udig.project.internal.command.MapCommand#run() */ @SuppressWarnings("deprecation") public void run(IProgressMonitor monitor) throws Exception { monitor.beginTask(Messages.WriteFeatureChangesCommand_runTask, 3); SubProgressMonitor subProgressMonitor = new SubProgressMonitor(monitor, 1); editFeature = featureProvider.get(subProgressMonitor); subProgressMonitor.done(); store = storeProvider.get(subProgressMonitor); if (editFeature == null || store == null) { noChange = true; return; } FeatureType featureType = editFeature.getFeatureType(); FilterFactory factory = FilterFactoryFinder.createFilterFactory(); subProgressMonitor = new SubProgressMonitor(monitor, 1); subProgressMonitor.done(); filter = factory.createFidFilter(editFeature.getID()); FeatureCollection results = store.getFeatures(filter); FeatureIterator reader = results.features(); try { if (reader.hasNext()) { try { store.modifyFeatures( featureType.getAttributeTypes(), editFeature.getAttributes(new Object[featureType.getAttributeCount()]), filter); } catch (Exception e) { ProjectPlugin.log("", e); // $NON-NLS-1$ noChange = true; } } else { added = true; store.addFeatures( new StaticFeatureCollection(Collections.singleton(editFeature), featureType)); } } finally { if (reader != null) reader.close(); } }