CoordinateReferenceSystem crs = null; try { crs = CRS.decode("epsg:26910"); System.out.println("got "+crs); } catch (FactoryException e) { // TODO Auto-generated catch block e.printStackTrace(); }
public void valueChanged(ListSelectionEvent e) { int index = e.getFirstIndex(); if(index>0){ try{ selectedCRS = (CoordinateReferenceSystem) getSelectedItem(); }catch(FactoryException ex){ ex.printStackTrace(); } } } });
private static void forceSRS(GetMapRequest getMap, String srs) { getMap.setSRS(srs); try { getMap.setCrs(CRS.decode(srs)); } catch (NoSuchAuthorityCodeException e) { e.printStackTrace(); } catch (FactoryException e) { e.printStackTrace(); } }
private static void forceSRS(GetMapRequest getMap, String srs) { getMap.setSRS(srs); try { getMap.setCrs( CRS.decode(srs) ); } catch (NoSuchAuthorityCodeException e) { e.printStackTrace(); } catch (FactoryException e) { e.printStackTrace(); } }
private ReferencedEnvelope computeReprojectedBounds() { final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(westBound, northBound, eastBound, southBound); final ReferencedEnvelope boundsEnvelope = new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); ReferencedEnvelope targetEnvelope = null; try { targetEnvelope = boundsEnvelope.transform(targetCRS, true); } catch (TransformException e) { e.printStackTrace(); } catch (FactoryException e) { e.printStackTrace(); } if (targetEnvelope == null) { throw new OperatorException("Cannot compute reprojected bounds"); } return targetEnvelope; //new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight()); }
private Point transformPoint(Point point) { CoordinateReferenceSystem sourceCRS = CRSUtils.getCRS(point.getSRID()); CoordinateReferenceSystem targetCRS = crs; try { MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); return CRSUtils.transformPoint(point, transform); } catch (FactoryException e) { e.printStackTrace(); return null; } } /**
public void apply() { try { context.setCoordinateReferenceSystem(liste.getCRS()); } catch (NoSuchAuthorityCodeException ex) { ex.printStackTrace(); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } }
private boolean verifyTargetCrs(MosaicFormModel formModel) { try { final CoordinateReferenceSystem crs = formModel.getTargetCRS(); if (crs == null) { showErrorDialog("No 'Coordinate Reference System' selected."); return false; } } catch (FactoryException e) { e.printStackTrace(); showErrorDialog("No 'Coordinate Reference System' selected.\n" + e.getMessage()); return false; } return true; }
private boolean verifyTargetCrs(S2tbxMosaicFormModel formModel) { try { final CoordinateReferenceSystem crs = formModel.getTargetCRS(); if (crs == null) { showErrorDialog("No 'Coordinate Reference System' selected."); return false; } } catch (FactoryException e) { e.printStackTrace(); showErrorDialog("No 'Coordinate Reference System' selected.\n" + e.getMessage()); return false; } return true; }
private boolean verfiyTargetCrs(MosaicFormModel formModel) { try { final CoordinateReferenceSystem crs = formModel.getTargetCRS(); if (crs == null) { showErrorDialog("No 'Coordinate Reference System' selected."); return false; } } catch (FactoryException e) { e.printStackTrace(); showErrorDialog("No 'Coordinate Reference System' selected.\n" + e.getMessage()); return false; } return true; }
public ReferencedEnvelope getLayerBounds() throws IOException { ReferencedEnvelope env; CoordinateReferenceSystem sourceCrs; env = layer[0].getBounds(); sourceCrs = env.getCoordinateReferenceSystem(); if (env != null) { try { if ((sourceCrs != null) && (crs != null) && !CRS.equalsIgnoreMetadata(sourceCrs, crs)) { env = env.transform(crs, true); } } catch (FactoryException e) { e.printStackTrace(); } catch (TransformException e) { e.printStackTrace(); } } return env; }
@Override public void propertyChange(PropertyChangeEvent arg0) { super.propertyChange(arg0); MapContext context = renderingStrategy.getContext(); try { selectionMapContext.setCoordinateReferenceSystem(context.getCoordinateReferenceSystem()); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } selectionStrategy.refresh(); }
/** * Determines the transformation from the coordinate reference system of * <tt>source</tt> to the one of <tt>target</tt>. * * @param source * a geometry. * @param target * a geometry. * @return a transformation or <tt>null</tt> if the transformation could not * be determined. */ public static MathTransform findTransform(Geometry source, Geometry target) { CoordinateReferenceSystem sourceCRS = getCRS(source.getSRID()); CoordinateReferenceSystem targetCRS = getCRS(target.getSRID()); try { return CRS.findMathTransform(sourceCRS, targetCRS); } catch (FactoryException e) { e.printStackTrace(); return null; } }
/** * Determines the transformation from the coordinate reference system of * <tt>source</tt> to the one of <tt>target</tt>. * * @param source * a geometry. * @param target * a geometry. * @return a transformation or <tt>null</tt> if the transformation could not * be determined. */ public static MathTransform findTransform(Geometry source, Geometry target) { CoordinateReferenceSystem sourceCRS = getCRS(source.getSRID()); CoordinateReferenceSystem targetCRS = getCRS(target.getSRID()); try { return CRS.findMathTransform(sourceCRS, targetCRS); } catch (FactoryException e) { e.printStackTrace(); return null; } }
private void adjusteContexts() { MapContext context = renderingStrategy.getContext(); if (!context.getCoordinateReferenceSystem().equals(memoryMapContext.getCoordinateReferenceSystem())) { try { memoryMapContext.setCoordinateReferenceSystem(context.getCoordinateReferenceSystem()); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } } memoryStrategy.setMapArea(renderingStrategy.getMapArea()); memoryStrategy.refresh(); }
@Override protected void mapAreaChanged(StrategyEvent event) { super.mapAreaChanged(event); MapContext context = renderingStrategy.getContext(); try { selectionMapContext.setCoordinateReferenceSystem(context.getCoordinateReferenceSystem()); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } selectionStrategy.setMapArea(event.getMapArea()); }
@Override protected void mapContextChanged(StrategyEvent event) { super.mapContextChanged(event); if (event.getContext() != oldMapcontext) { oldMapcontext = event.getContext(); selectionMapContext.clearLayerList(); copies.clear(); MapContext context = event.getContext(); try { selectionMapContext.setCoordinateReferenceSystem(context.getCoordinateReferenceSystem()); selectionStrategy.setMapArea(renderingStrategy.getMapArea()); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } } }
@Override protected void setRendering(boolean render) { super.setRendering(render); MapContext context = renderingStrategy.getContext(); try { selectionMapContext.setCoordinateReferenceSystem(context.getCoordinateReferenceSystem()); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } selectionStrategy.setMapArea(renderingStrategy.getMapArea()); selectionStrategy.refresh(); }
@Override public AbstractLayerSourceAssistantPage getNextPage() { final LayerSourcePageContext context = getContext(); try { final Product product = context.getAppContext().getSelectedProduct(); final GeoPos referencePos = ProductUtils.getCenterGeoPos(product); final CoordinateReferenceSystem crs = crsSelectionPanel.getCrs(referencePos); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS, crs); return new ShapefileAssistantPage3(); } catch (FactoryException e) { e.printStackTrace(); context.showErrorDialog("Could not create CRS:\n" + e.getMessage()); } return null; }
@Override public AbstractLayerSourceAssistantPage getNextPage() { final LayerSourcePageContext context = getContext(); try { final Product product = SnapApp.getDefault().getSelectedProduct(VIEW); final GeoPos referencePos = ProductUtils.getCenterGeoPos(product); final CoordinateReferenceSystem crs = crsSelectionPanel.getCrs(referencePos); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS, crs); return new ShapefileAssistantPage3(); } catch (FactoryException e) { e.printStackTrace(); context.showErrorDialog("Could not create CRS:\n" + e.getMessage()); } return null; }