Package org.opengis.referencing.cs

Examples of org.opengis.referencing.cs.CoordinateSystem


    /**
     * Tests the (longitude, latitude) axis order for EPSG:4326.
     */
    public void testForcedAxisOrder() throws NoSuchAuthorityCodeException, FactoryException {
        final CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true);
        final CoordinateSystem cs = crs.getCoordinateSystem();
        assertEquals(2, cs.getDimension());

        CoordinateSystemAxis axis0 = cs.getAxis(0);
        assertEquals("Long", axis0.getAbbreviation());

        CoordinateSystemAxis axis1 = cs.getAxis(1);
        assertEquals("Lat", axis1.getAbbreviation());

        final CoordinateReferenceSystem standard = CRS.decode("EPSG:4326");
        assertFalse("Should not be (long,lat) axis order.", CRS.equalsIgnoreMetadata(crs, standard));

View Full Code Here


        }
        /*
         * Creates a new array of 'Format' objects, one for each dimension.
         * The format subclasses are infered from coordinate system axis.
         */
        final CoordinateSystem cs = crs.getCoordinateSystem();
        epochs   = null;
        toMillis = null;
        formats  = new Format[cs.getDimension()];
        types    = new byte[formats.length];
        for (int i=0; i<formats.length; i++) {
            final Unit<?> unit = cs.getAxis(i).getUnit();
            /////////////////
            ////  Angle  ////
            /////////////////
            if (NonSI.DEGREE_ANGLE.equals(unit)) {
                if (angleFormat == null) {
                    angleFormat = new AngleFormat("DD°MM.m'", locale);
                }
                formats[i] = angleFormat;
                final AxisDirection axis = cs.getAxis(i).getDirection().absolute();
                if (AxisDirection.EAST.equals(axis)) {
                    types[i] = LONGITUDE;
                } else if (AxisDirection.NORTH.equals(axis)) {
                    types[i] = LATITUDE;
                } else {
View Full Code Here

                               final StringBuffer    toAppendTo,
                               final FieldPosition   position)
            throws IllegalArgumentException
    {
        final int dimension = point.getDimension();
        final CoordinateSystem cs;
        if (crs != null) {
            if (dimension != formats.length) {
                throw new MismatchedDimensionException(Errors.format(
                            ErrorKeys.MISMATCHED_DIMENSION_$3, "point", dimension, formats.length));
            }
            cs = crs.getCoordinateSystem();
        } else {
            cs = null;
        }
        for (int i=0; i<dimension; i++) {
            final double value = point.getOrdinate(i);
            final int fi = Math.min(i, formats.length-1);
            final Object object;
            final byte type = types[fi];
            switch (type) {
                default:        object=Double.valueOf(value); break;
                case LONGITUDE: object=new Longitude (value); break;
                case LATITUDE:  object=new Latitude  (value); break;
                case ANGLE:     object=new Angle     (value); break;
                case DATE: {
                    final CoordinateSystemAxis axis = cs.getAxis(i);
                    long offset = Math.round(toMillis[fi].convert(value));
                    if (AxisDirection.PAST.equals(axis.getDirection())) {
                        offset = -offset;
                    }
                    object = new Date(epochs[fi] + offset);
                    break;
                }
            }
            if (i != 0) {
                toAppendTo.append(separator);
            }
            formats[fi].format(object, toAppendTo, dummy);
            /*
             * If the formatted value is a number, append the units.
             */
            if (type==0 && cs!=null) {
                final Unit<?> unit = cs.getAxis(i).getUnit();
                if (unit != null) {
                    if (unitFormat == null) {
                        unitFormat = UnitFormat.getInstance();
                    }
                    final String asText = unitFormat.format(unit);
View Full Code Here

            //
            final Object rx = kvp.get("resx");
            final Object ry = kvp.get("resy");
            if (rx != null && ry != null) {
                // get resx e resy but correct also the sign for them taking into account
              final CoordinateSystem cs=crs.getCoordinateSystem();
              final AxisDirection northingDirection=cs.getAxis(1).getDirection();
              final int yAxisCorrection=AxisDirection.NORTH.equals(northingDirection)?-1:1;
              final AxisDirection eastingDirection=cs.getAxis(0).getDirection();
              final int xAxisCorrection=AxisDirection.EAST.equals(eastingDirection)?1:-1;
                final double resX = Double.parseDouble((String) rx)*xAxisCorrection;
                final double resY = Double.parseDouble((String) ry)*yAxisCorrection;
               

View Full Code Here

  }

  private static int indexOf(
      final CoordinateReferenceSystem crs,
      final Set<AxisDirection> direction ) {
    final CoordinateSystem cs = crs.getCoordinateSystem();
    for (int index = 0; index < cs.getDimension(); index++) {
      final CoordinateSystemAxis axis = cs.getAxis(index);
      if (direction.contains(axis.getDirection())) {
        return index;
      }
    }
    return -1;
View Full Code Here

                    "WCSEnvelope coordinate reference system cannot be null");
        }
        this.crs = crs;

        // initialize the longitude dimension, if we have a longitude, that is
        CoordinateSystem cs = crs.getCoordinateSystem();
        this.dimensions = cs.getDimension();
        this.ordinates = new double[dimensions * 2];
        for (int i = 0; i < dimensions; i++) {
            CoordinateSystemAxis axis = cs.getAxis(i);
            if (CRS.equalsIgnoreMetadata(axis, DefaultCoordinateSystemAxis.LONGITUDE)) {
                longitudeDimension = i;
                break;
            }
        }
View Full Code Here

         * @param axisLabels
         * @throws IOException
         */
        public void handleBoundedBy(final GeneralEnvelope envelope, boolean axisSwap, String srsName, String axisLabels, WCSDimensionsHelper dimensionHelper) throws IOException {
            final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
            final CoordinateSystem cs = crs.getCoordinateSystem();

            // TODO time
            String uomLabels = extractUoM(crs, cs.getAxis(axisSwap ? 1 : 0).getUnit()) + " "
                    + extractUoM(crs, cs.getAxis(axisSwap ? 0 : 1).getUnit());

            // time and elevation dimensions management
            boolean hasElevation = false;
            boolean hasTime = false;
            if (dimensionHelper != null) {
                if (dimensionHelper.getElevationDimension() != null) {
                    uomLabels = uomLabels + " m"; //TODO: Check elevation uom
                    hasElevation = true;
                }
                if (dimensionHelper.getTimeDimension() != null) {
                    uomLabels = uomLabels + " s";
                    hasTime = true;
                }
            }
            final int srsDimension = cs.getDimension() + (hasElevation ? 1 : 0);

            // Setting up envelope bounds (including elevation)
            final String lower = new StringBuilder()
                    .append(envelope.getLowerCorner().getOrdinate(axisSwap ? 1 : 0)).append(" ")
                    .append(envelope.getLowerCorner().getOrdinate(axisSwap ? 0 : 1))
View Full Code Here

    public int[] getAxesIndexes(final Envelope envelope, final List<String> axesAbbreviations){
        Utilities.ensureNonNull("envelope", envelope);
        Utilities.ensureNonNull("dimensionNames", axesAbbreviations);

        final CoordinateReferenceSystem crs= envelope.getCoordinateReferenceSystem();
        final CoordinateSystem cs=crs.getCoordinateSystem();
        final int crsDimension=cs.getDimension();
               
        final int dimension=axesAbbreviations.size();
        final int[] retValue= new int[dimension];
        for (int i = 0; i < dimension; i++) {
           
            // abbreviation we are looking for
            final String axisAbbreviation=axesAbbreviations.get(i);
            int pos=-1;
            // search for this dimension in cs axes
            for(int j=0;j<crsDimension;j++){
                // check exact abbreviation
                CoordinateSystemAxis axis = cs.getAxis(j);
                if(getAxisLabel(axis).equals(axisAbbreviation)){
                    pos=j; // FOUND!!!
                    break;
                }
            }
View Full Code Here

            upper = upper + geometry.getGridRange().getHigh(i) + " ";
        }
        writer.write("<grid dimension = \"" + dimensions + "\">\n");
        writer.write("<low>" + lower + "</low>\n");
        writer.write("<high>" + upper + "</high>\n");
        final CoordinateSystem cs = crs.getCoordinateSystem();
        for (int i=0; i < cs.getDimension(); i++) {
            writer.write("<axisName>" + cs.getAxis(i).getName().getCode() + "</axisName>\n");
        }
        if(geometry.getGridToCRS() instanceof AffineTransform) {
            AffineTransform aTX = (AffineTransform) geometry.getGridToCRS();
            writer.write("<geoTransform>");
                writer.write("<scaleX>" + aTX.getScaleX() + "</scaleX>\n");
View Full Code Here

       
        // handle axes switch for geographic crs
        final boolean axesSwitch= crs instanceof GeographicCRS &&swapAxes;
       
        // additional fields for CRS
        final CoordinateSystem cs=crs.getCoordinateSystem();
       
        final int dimension=cs.getDimension();
        // loop through dimensions
        final ArrayList<String> retValue=new ArrayList<String>();
        if (!axesSwitch) {
            for (int i = 0; i < dimension; i++) {
                CoordinateSystemAxis axis = cs.getAxis(i);
                retValue.add(getAxisLabel(axis)); // use axis abbreviation
            }
        } else {
            int northing=-1, easting=-1;
            for (int i = 0; i < dimension; i++) {
                final CoordinateSystemAxis axis = cs.getAxis(i);
                if (Math.abs(DefaultCoordinateSystemAxis.getAngle(axis.getDirection(), DefaultCoordinateSystemAxis.LONGITUDE.getDirection()))<1E-6) {
                    easting = i;
                } else if (Math.abs(DefaultCoordinateSystemAxis.getAngle(axis.getDirection(), DefaultCoordinateSystemAxis.LATITUDE.getDirection()))<1E-6){
                    northing = i;
                }
View Full Code Here

TOP

Related Classes of org.opengis.referencing.cs.CoordinateSystem

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.