Package org.opengis.referencing.crs

Examples of org.opengis.referencing.crs.CoordinateReferenceSystem


        public String getColumnText( Object element, int columnIndex ) {
            assert element instanceof Data;
            assert columnIndex < 3;

            Data data=(Data)element;
            CoordinateReferenceSystem crs = data.getCRS();
      switch( columnIndex ) {
            case 0:
                if( data.getName()==null ){
                    return wrapped.getText(data.getResource());
                }else{
                    return data.getName();
                }
            case 1:
              if( crs==null )
                return "undefined";
                return crs.getName().toString();

            default:
                break;
            }
            throw new RuntimeException("Don't know how to handle column 3"); //$NON-NLS-1$
View Full Code Here


        if (featureSource == null) {
            return;
        }
        GeometryDescriptor geometryDescriptor = featureSource.getSchema().getGeometryDescriptor();
        ReferencedEnvelope bounds = ApplicationGIS.getActiveMap().getViewportModel().getBounds();
        CoordinateReferenceSystem mapCrs = bounds.getCoordinateReferenceSystem();
       
        ReferencedEnvelope featureBounds = featureSource.getBounds();
        if (featureBounds == null || featureBounds.isNull()){
            return;
        }
        CoordinateReferenceSystem featureCrs = featureBounds.getCoordinateReferenceSystem();
        ReferencedEnvelope tBounds = bounds.transform(featureCrs, true);
       
        boolean crsEqual = CRS.equalsIgnoreMetadata(featureCrs, mapCrs);
        MathTransform mathTransform = CRS.findMathTransform(featureCrs, mapCrs, true);
       
View Full Code Here

       
        final Button crsButton = new Button(mainComposite, SWT.PUSH);
        crsButton.setText("...");
        crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
            public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
                CoordinateReferenceSystem crs = ApplicationGIS.getActiveMap().getViewportModel().getCRS();
                CRSChooserDialog dialog = new CRSChooserDialog(crsButton.getShell(), crs);
                int code = dialog.open();
                if (Window.OK == code) {
                    CoordinateReferenceSystem result = dialog.getResult();
                    crsText.setText(result.getName().toString());
                    crsText.setData(result);
                    newCrs = result;
                }
                validate();
            }
View Full Code Here

                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
View Full Code Here

                IMap activeMap = ApplicationGIS.getActiveMap();
                ViewportModel viewportModel = (ViewportModel) activeMap.getViewportModel();
                ReferencedEnvelope bounds = viewportModel.getBounds();

                CoordinateReferenceSystem mapCrs = viewportModel.getCRS();
                CoordinateReferenceSystem imageCrs = DefaultGeographicCRS.WGS84;
                try {
                    MathTransform transform = CRS.findMathTransform(mapCrs, imageCrs);
                    Envelope targetEnv = JTS.transform(bounds, transform);
                    double west = targetEnv.getMinX();
                    double north = targetEnv.getMaxY();
                    double east = targetEnv.getMaxX();
                    double south = targetEnv.getMinY();

                    if (west < -180) {
                        west = -180;
                    }
                    if (west > 180) {
                        west = 180;
                    }
                    if (north < -90) {
                        north = -90;
                    }
                    if (north > 90) {
                        north = 90;
                    }
                    if (east < -180) {
                        east = -180;
                    }
                    if (east > 180) {
                        east = 180;
                    }
                    if (south < -90) {
                        south = -90;
                    }
                    if (south > 90) {
                        south = 90;
                    }
                    west = 180.0 + west;
                    north = 90.0 + north;
                    east = 180.0 + east;
                    south = 90.0 + south;
                    double width = east - west;
                    double height = north - south;
                    if (width < 1) {
                        width = 1;
                    }
                    if (height < 1) {
                        height = 1;
                    }

                    int x = (int) ((double) canvasBounds.width * west / 360.0);
                    int y = (int) ((double) h * north / 180.0);
                    int fw = (int) ((double) canvasBounds.width * width / 360.0);
                    if (fw <= 1)
                        fw = 2;
                    int fh = (int) ((double) h * height / 180.0);
                    if (fh <= 1)
                        fh = 2;
                    int newy = h - y;
                    e.gc.setForeground(color);
                    e.gc.setBackground(color);
                    e.gc.setAlpha(80);
                    e.gc.fillRectangle(x, newy, fw, fh);

                    e.gc.drawLine(x + fw / 2, 0, x + fw / 2, newy);
                    // e.gc.drawLine(x + fw / 2, newy + fh, x + fw / 2, h);
                    //
                    e.gc.drawLine(0, newy + fh / 2, x, newy + fh / 2);
                    e.gc.drawLine(x + fw, newy + fh / 2, canvasBounds.width, newy + fh / 2);

                } catch (FactoryException e1) {
                    e1.printStackTrace();
                } catch (TransformException e1) {
                    e1.printStackTrace();
                }

            }
        });

        // Label fillLabel = new Label(parent, SWT.NONE);
        // fillLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

        Group geonamesGroup = new Group(parent, SWT.NONE);
        geonamesGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        geonamesGroup.setLayout(new GridLayout(4, false));
        geonamesGroup.setText("Geonames");

        Label availableLabel = new Label(geonamesGroup, SWT.NONE);
        availableLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
        availableLabel.setText("Available geonames data");

        URL folderUrl = Platform.getBundle(JGrassToolsPlugin.PLUGIN_ID).getResource("/geonamesfiles");
        String folderPath = null;
        try {
            folderPath = FileLocator.toFileURL(folderUrl).getPath();
            folderFile = new File(folderPath);

            String[] namesArray = loadGeonamesFiles();

            countriesCombo = new Combo(geonamesGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            countriesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            countriesCombo.setItems(namesArray);
            countriesCombo.select(0);
            countriesCombo.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected( SelectionEvent e ) {
                    int selectionIndex = countriesCombo.getSelectionIndex();
                    String item = countriesCombo.getItem(selectionIndex);
                    final String file = folderFile.getAbsolutePath() + File.separator + item + ".txt";

                    IRunnableWithProgress operation = new IRunnableWithProgress(){
                        public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException {
                            try {
                                populatePlacesMap(placesMap, file);
                            } catch (FileNotFoundException e1) {
                                e1.printStackTrace();
                            } catch (IOException e1) {
                                e1.printStackTrace();
                            }
                        }
                    };
                    PlatformGIS.runInProgressDialog("Loading geonames data...", true, operation, true);
                }
            });

            Button addNewButton = new Button(geonamesGroup, SWT.PUSH);
            addNewButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            addNewButton.setText("+");
            addNewButton.setToolTipText("Add a new geonames file (get it at http://download.geonames.org/export/dump/)");
            addNewButton.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected( SelectionEvent e ) {
                    FileDialog fileDialog = new FileDialog(countriesCombo.getShell(), SWT.OPEN);
                    fileDialog.setFilterExtensions(new String[]{"*.txt"});
                    String newFilePath = fileDialog.open();
                    try {
                        if (newFilePath != null) {
                            File newFile = new File(newFilePath);
                            if (newFile.exists()) {
                                File copiedFile = new File(folderFile, newFile.getName());
                                FileUtils.copyFile(newFile, copiedFile);
                            }
                        }
                        String[] geonamesFiles = loadGeonamesFiles();
                        if (geonamesFiles.length > 0) {
                            countriesCombo.setItems(geonamesFiles);
                            countriesCombo.select(0);
                        } else {
                            countriesCombo.setItems(new String[]{"   --   "});
                        }
                    } catch (IOException e1) {
                        String message = "An error occurred while copying the new geonames file into the application.";
                        ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassToolsPlugin.PLUGIN_ID, e1);
                        e1.printStackTrace();
                    }
                }
            });

            Button removeButton = new Button(geonamesGroup, SWT.PUSH);
            removeButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            removeButton.setText("-");
            removeButton.setToolTipText("Remove a geonames file");
            removeButton.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected( SelectionEvent e ) {
                    int selectionIndex = countriesCombo.getSelectionIndex();
                    String item = countriesCombo.getItem(selectionIndex);

                    try {
                        File namesFile = new File(folderFile, item + ".txt");
                        if (namesFile.exists()) {
                            FileUtils.forceDelete(namesFile);
                        }
                        String[] geonamesFiles = loadGeonamesFiles();
                        if (geonamesFiles.length > 0) {
                            countriesCombo.setItems(geonamesFiles);
                            countriesCombo.select(0);
                        } else {
                            countriesCombo.setItems(new String[]{"   --   "});
                        }
                    } catch (IOException e1) {
                        String message = "An error occurred while removing the old geonames file into the application.";
                        ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassToolsPlugin.PLUGIN_ID, e1);
                        e1.printStackTrace();
                    }
                }
            });

            Group placesGroup = new Group(geonamesGroup, SWT.NONE);
            GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
            layoutData.horizontalSpan = 4;
            placesGroup.setLayoutData(layoutData);
            placesGroup.setLayout(new GridLayout(2, false));
            placesGroup.setText("places");

            placesMap = new HashMap<String, Coordinate>(1000);
            populatePlacesMap(placesMap, first.getAbsolutePath());
            keySet = placesMap.keySet();

            final Text placesText = new Text(placesGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            placesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            placesText.setText("");

            Button searchButton = new Button(placesGroup, SWT.PUSH);
            searchButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            searchButton.setText("search");
            searchButton.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected( SelectionEvent e ) {
                    String text = placesText.getText();
                    if (text.length() < 3) {
                        MessageBox msgBox = new MessageBox(placesText.getShell(), SWT.ICON_WARNING);
                        msgBox.setMessage("At least 3 letters are needed to do a search.");
                        msgBox.open();
                        return;
                    }

                    List<String> matchedList = new ArrayList<String>();
                    for( String name : keySet ) {
                        if (name.toLowerCase().matches(".*" + text.toLowerCase() + ".*")) {
                            matchedList.add(name);
                        }
                    }
                    String[] matchedArray = (String[]) matchedList.toArray(new String[matchedList.size()]);
                    Arrays.sort(matchedArray);
                    placesCombo.setItems(matchedArray);
                    placesCombo.select(0);
                }
            });

            placesCombo = new Combo(placesGroup, SWT.DROP_DOWN);
            placesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            placesCombo.setItems(new String[]{ENTER_SEARCH_STRING});

            Button goButton = new Button(placesGroup, SWT.PUSH);
            goButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            goButton.setText("go");
            goButton.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected( SelectionEvent e ) {
                    IMap map = ApplicationGIS.getActiveMap();
                    if (map.getMapLayers().size() < 1) {
                        return;
                    }

                    ReferencedEnvelope bounds = map.getViewportModel().getBounds();
                    CoordinateReferenceSystem mapCrs = map.getViewportModel().getCRS();

                    try {
                        GeometryFactory gF = new GeometryFactory();
                        CoordinateReferenceSystem placeCrs = CRS.decode("EPSG:4326");
                        // transform coordinates before check
                        MathTransform transform = CRS.findMathTransform(placeCrs, mapCrs, true);
                        // jts geometry
                        int selectionIndex = placesCombo.getSelectionIndex();
                        String item = placesCombo.getItem(selectionIndex);
View Full Code Here

        crsButton.setText(" Choose CRS ");
        crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
            public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
                final ChooseCoordinateReferenceSystemDialog crsChooser = new ChooseCoordinateReferenceSystemDialog();
                crsChooser.open(new Shell(Display.getDefault()));
                CoordinateReferenceSystem crs = crsChooser.getCrs();
                if (crs == null)
                    return;
                crsText.setText(crs.getName().toString());
                readCrs = crs;
                checkFinish();
            }
        });
View Full Code Here

    }
   
    public static List<SimpleFeature> info2( ILayer layer, ReferencedEnvelope bbox, IProgressMonitor monitor ) throws Exception{
        FeatureSource<SimpleFeatureType, SimpleFeature> source = layer.getResource( FeatureSource.class, null );
        SimpleFeatureType type = source.getSchema();
        CoordinateReferenceSystem crs = layer.getCRS();
       
        if( !bbox.getCoordinateReferenceSystem().equals( crs )) {
            bbox = bbox.transform(crs, true);
        }
        FilterFactory2 factory = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
View Full Code Here

    IMap map;
    if (context != null) {

      map = context.getMap();
      CoordinateReferenceSystem crs = getCurrentMapCrs(map);

      // create the mapGraphics
      try {
        createTheMapGraphic(map);
      } catch (IOException e) {
View Full Code Here

        addPage(mainPage);
    }

    public boolean performFinish() {

        final CoordinateReferenceSystem crs = mainPage.getCrs();
        final File csvFile = mainPage.getCsvFile();
        final String separator = mainPage.getSeparator();
        final LinkedHashMap<String, Integer> fieldsAndTypesIndex = mainPage.getFieldsAndTypesIndex();

        /*
 
View Full Code Here

                    String msg = Messages.ReshapeOperation_5;
                    throw new ReshapeException(format(msg, name));
                }
            }
            if( Geometry.class.isAssignableFrom( binding )){
                CoordinateReferenceSystem crs;
                AttributeType originalAttributeType = originalFeatureType.getType(name);
                if( originalAttributeType == null && originalAttributeType instanceof GeometryType ) {
                    crs = ((GeometryType)originalAttributeType).getCoordinateReferenceSystem();
                } else {
                    crs = originalFeatureType.getCoordinateReferenceSystem();
View Full Code Here

TOP

Related Classes of org.opengis.referencing.crs.CoordinateReferenceSystem

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.