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;
}
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));
}
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));
}
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));
}
}
}
}
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();
}
Aggregations