Search in sources :

Example 46 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class Transform method getParameterValues.

/**
 * Returns a copy of the parameter values for this parameterized object.
 */
@Override
public ParameterValueGroup getParameterValues() {
    final ParameterValueGroup pg = getParameterDescriptors().createValue();
    pg.parameter("srcdefn").setValue(source.getCode().trim());
    pg.parameter("dstdefn").setValue(target.getCode().trim());
    return pg;
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup)

Example 47 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class Proj4FactoryTest method testParameterizedTransform.

/**
 * Tests {@link Proj4Factory#createParameterizedTransform(ParameterValueGroup)}.
 *
 * @throws FactoryException if an error occurred while creating the CRS objects.
 * @throws TransformException if an error occurred while projecting a test point.
 */
@Test
public void testParameterizedTransform() throws FactoryException, TransformException {
    final Proj4Factory factory = Proj4Factory.INSTANCE;
    final ParameterValueGroup pg = factory.getDefaultParameters("merc");
    pg.parameter("a").setValue(6378137.0);
    pg.parameter("b").setValue(6356752.314245179);
    testMercatorProjection(factory.createParameterizedTransform(pg));
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Example 48 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class Proj4ParserTest method testKilometres.

/**
 * Tests parsing a definition string with axes in kilometres.
 *
 * @throws FactoryException if the parsing failed.
 */
@Test
public void testKilometres() throws FactoryException {
    final Proj4Parser parser = new Proj4Parser("+proj=merc +to_meter=0.001");
    assertInstanceOf("method", Mercator1SP.class, parser.method(opFactory));
    final ParameterValueGroup pg = parser.parameters();
    assertEquals("scale_factor", pg.parameter("scale_factor").getValue(), 1.0);
    assertEquals(Units.KILOMETRE, parser.unit(false));
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Example 49 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class CRSBuilder method verify.

/**
 * Verifies if the user-defined conversion created from GeoTIFF values
 * matches the given conversion created from the EPSG geodetic dataset.
 * This method does not verify the EPSG code of the given conversion.
 *
 * @param  projection  the conversion created from the EPSG geodetic dataset.
 */
private void verify(final Conversion projection, final Unit<Angle> angularUnit, final Unit<Length> linearUnit) throws FactoryException {
    final Unit<Angle> azimuthUnit = createUnit(GeoKeys.AzimuthUnits, (short) 0, Angle.class, Units.DEGREE);
    final String type = getAsString(GeoKeys.CoordTrans);
    if (type != null) {
        /*
             * Compare the name of the map projection declared in the GeoTIFF file with the name
             * of the projection used by the EPSG geodetic dataset.
             */
        final OperationMethod method = projection.getMethod();
        if (!IdentifiedObjects.isHeuristicMatchForName(method, type)) {
            Identifier expected = IdentifiedObjects.getIdentifier(method, Citations.GEOTIFF);
            if (expected == null) {
                expected = IdentifiedObjects.getIdentifier(method, null);
            }
            warning(Resources.Keys.NotTheEpsgValue_5, IdentifiedObjects.getIdentifierOrName(projection), expected.getCode(), GeoKeys.name(GeoKeys.CoordTrans), type, "");
        }
        /*
             * Compare the parameter values with the ones declared in the EPSG geodetic dataset.
             */
        final ParameterValueGroup parameters = projection.getParameterValues();
        for (final short key : remainingKeys()) {
            final Unit<?> unit;
            switch(GeoKeys.unitOf(key)) {
                case GeoKeys.RATIO:
                    unit = Units.UNITY;
                    break;
                case GeoKeys.LINEAR:
                    unit = linearUnit;
                    break;
                case GeoKeys.ANGULAR:
                    unit = angularUnit;
                    break;
                case GeoKeys.AZIMUTH:
                    unit = azimuthUnit;
                    break;
                default:
                    continue;
            }
            try {
                verify(projection, parameters.parameter("GeoTIFF:" + key).doubleValue(unit), key, unit);
            } catch (ParameterNotFoundException e) {
                warning(Resources.Keys.UnexpectedParameter_2, type, GeoKeys.name(key));
            }
        }
    }
}
Also used : Identifier(org.opengis.metadata.Identifier) Angle(javax.measure.quantity.Angle) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ParameterNotFoundException(org.opengis.parameter.ParameterNotFoundException) OperationMethod(org.opengis.referencing.operation.OperationMethod)

Example 50 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project OpenTripPlanner by opentripplanner.

the class Renderer method generateStreamingGeotiffResponse.

private static Response generateStreamingGeotiffResponse(final GridCoverage2D coverage) {
    StreamingOutput streamingOutput = new StreamingOutput() {

        public void write(OutputStream outStream) {
            try {
                long t0 = System.currentTimeMillis();
                GeoTiffWriteParams wp = new GeoTiffWriteParams();
                wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
                wp.setCompressionType("LZW");
                ParameterValueGroup params = new GeoTiffFormat().getWriteParameters();
                params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp);
                new GeoTiffWriter(outStream).write(coverage, (GeneralParameterValue[]) params.values().toArray(new GeneralParameterValue[1]));
                // new GeoTiffWriter(outStream).write(coverage, null); //wasn't this line writing twice and trashing compressed version?
                long t1 = System.currentTimeMillis();
                LOG.debug("wrote geotiff in {}msec", t1 - t0);
            } catch (Exception e) {
                LOG.error("exception while preparing geotiff : {}", e.getMessage());
                throw new WebApplicationException(e);
            }
        }
    };
    CacheControl cc = new CacheControl();
    cc.setMaxAge(3600);
    cc.setNoCache(false);
    return Response.ok(streamingOutput).type("image/geotiff").cacheControl(cc).build();
}
Also used : GeneralParameterValue(org.opengis.parameter.GeneralParameterValue) GeoTiffFormat(org.geotools.gce.geotiff.GeoTiffFormat) WebApplicationException(javax.ws.rs.WebApplicationException) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) OutputStream(java.io.OutputStream) GeoTiffWriteParams(org.geotools.gce.geotiff.GeoTiffWriteParams) StreamingOutput(javax.ws.rs.core.StreamingOutput) GeoTiffWriter(org.geotools.gce.geotiff.GeoTiffWriter) CacheControl(javax.ws.rs.core.CacheControl) WebApplicationException(javax.ws.rs.WebApplicationException)

Aggregations

ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)98 Test (org.junit.Test)54 DependsOnMethod (org.apache.sis.test.DependsOnMethod)27 GeneralParameterValue (org.opengis.parameter.GeneralParameterValue)12 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)11 OperationMethod (org.opengis.referencing.operation.OperationMethod)11 ParameterValue (org.opengis.parameter.ParameterValue)8 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7 ParameterNotFoundException (org.opengis.parameter.ParameterNotFoundException)7 SingleOperation (org.opengis.referencing.operation.SingleOperation)6 FactoryException (org.opengis.util.FactoryException)6 DefaultGeodeticDatum (org.apache.sis.referencing.datum.DefaultGeodeticDatum)5 IdentifiedObject (org.opengis.referencing.IdentifiedObject)5 Matrix (org.opengis.referencing.operation.Matrix)5 ArrayList (java.util.ArrayList)4 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)4 ParameterDescriptorGroup (org.opengis.parameter.ParameterDescriptorGroup)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)4 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)4 URL (java.net.URL)3