Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Geotoolkit.org - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2001-2012, Open Source Geospatial Foundation (OSGeo)
* (C) 2009-2012, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotoolkit.referencing.operation.provider;
import java.util.Collections;
import javax.measure.unit.SI;
import net.jcip.annotations.Immutable;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.InvalidParameterValueException;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.GeocentricCRS;
import org.opengis.referencing.operation.Conversion;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.ReferenceIdentifier;
import org.geotoolkit.resources.Errors;
import org.geotoolkit.resources.Vocabulary;
import org.geotoolkit.parameter.DefaultParameterDescriptor;
import org.geotoolkit.metadata.iso.citation.Citations;
import org.geotoolkit.referencing.NamedIdentifier;
import org.geotoolkit.referencing.operation.MathTransformProvider;
import org.geotoolkit.referencing.operation.transform.GeocentricTransform;
import org.geotoolkit.internal.referencing.MathTransformDecorator;
import static org.geotoolkit.parameter.Parameters.*;
/**
* The provider for "Geographic/geocentric conversions" (EPSG:9602). This provider
* constructs transforms from {@linkplain GeographicCRS geographic} to {@linkplain GeocentricCRS
* geocentric} coordinate reference systems.
*
* By default, this provider creates a transform from a three-dimensional ellipsoidal coordinate
* system, which is the behavior implied in OGC's WKT. However a Geotk-specific {@code "dim"}
* parameter allows to transform from a two-dimensional ellipsoidal coordinate system instead.
*
* WARNING: The EPSG code is the same than the {@link GeocentricToEllipsoid}
* one. To avoid ambiguity, use the OGC name instead: {@code "Ellipsoid_To_Geocentric"}.
*
*
*
The following table summarizes the parameters recognized by this provider.
* For a more detailed parameter list, see the {@link #PARAMETERS} constant.
*
Operation name: {@code Ellipsoid_To_Geocentric}
*
*
Parameter name
Default value
*
{@code semi_major}
*
{@code semi_minor}
*
{@code dim}
3
*
*
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @version 3.20
*
* @see GeocentricTransform
* @see Geotk coordinate operations matrix
*
* @since 2.0
* @module
*/
@Immutable
public class EllipsoidToGeocentric extends MathTransformProvider {
/**
* Serial number for inter-operability with different versions.
*/
private static final long serialVersionUID = -5690807111952562344L;
/**
* The operation parameter descriptor for the {@code "semi_major"} parameter value.
* Valid values range from 0 to infinity. This parameter is mandatory and has no
* default value.
*
* @deprecated Invoke {@linkplain #PARAMETERS}.{@linkplain ParameterDescriptorGroup#descriptor(String)
* descriptor(String)} instead.
*/
@Deprecated
public static final ParameterDescriptor SEMI_MAJOR =
(ParameterDescriptor) PseudoMercator.PARAMETERS.descriptor("semi_major");
/**
* The operation parameter descriptor for the {@code "semi_minor"} parameter value.
* Valid values range from 0 to infinity. This parameter is mandatory and has no
* default value.
*
* @deprecated Invoke {@linkplain #PARAMETERS}.{@linkplain ParameterDescriptorGroup#descriptor(String)
* descriptor(String)} instead.
*/
@Deprecated
public static final ParameterDescriptor SEMI_MINOR =
(ParameterDescriptor) PseudoMercator.PARAMETERS.descriptor("semi_minor");
/**
* The operation parameter descriptor for the number of geographic dimension (2 or 3).
* This is a Geotk-specific argument. The default value is 3, which is the value
* implied in OGC's WKT.
*
* @deprecated Invoke {@linkplain #PARAMETERS}.{@linkplain ParameterDescriptorGroup#descriptor(String)
* descriptor(String)} instead.
*/
@Deprecated
public static final ParameterDescriptor DIM = DefaultParameterDescriptor.create(
Collections.singletonMap(NAME_KEY,
new NamedIdentifier(Citations.GEOTOOLKIT, "dim")),
3, 2, 3, false);
/**
* The group of all parameters expected by this coordinate operation.
* The following table lists the operation names and the parameters recognized by Geotk:
*
*
*
*
*
*
Name:
OGC:
Ellipsoid_To_Geocentric
*
Alias:
EPSG:
Geographic/geocentric conversions
*
Geotk:
Geocentric transform
*
Identifier:
EPSG:
9602
*
*
*
*
*
Name:
OGC:
semi_major
*
Alias:
EPSG:
Semi-major axis
*
*
*
*
Type:
{@code Double}
*
Obligation:
mandatory
*
Value range:
[0…∞) metres
*
*
*
*
*
Name:
OGC:
semi_minor
*
Alias:
EPSG:
Semi-minor axis
*
*
*
*
Type:
{@code Double}
*
Obligation:
mandatory
*
Value range:
[0…∞) metres
*
*
*
*
*
Name:
Geotk:
dim
*
*
*
*
Type:
{@code Integer}
*
Obligation:
optional
*
Value range:
[2…3]
*
Default value:
3
*
*
*
*/
public static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup("Ellipsoid_To_Geocentric");
/**
* Constructs the parameters group.
*/
static ParameterDescriptorGroup createDescriptorGroup(final String ogc) {
return UniversalParameters.createDescriptorGroup(new ReferenceIdentifier[] {
new NamedIdentifier(Citations.OGC, ogc),
new NamedIdentifier(Citations.EPSG, "Geographic/geocentric conversions"),
new IdentifierCode (Citations.EPSG, 9602),
new NamedIdentifier(Citations.GEOTOOLKIT, Vocabulary.formatInternational(
Vocabulary.Keys.GEOCENTRIC_TRANSFORM))
}, null, new ParameterDescriptor>[] {
SEMI_MAJOR, SEMI_MINOR, DIM
}, MapProjectionDescriptor.ADD_EARTH_RADIUS);
}
/**
* If this provider is for the 3D case, then {@code complement} is the provider for the 2D case.
* Conversely if this provider is for the 2D case, then {@code complement} is the provider for
* the 3D case.
*/
private final EllipsoidToGeocentric complement;
/**
* Constructs a provider with default parameters.
*/
public EllipsoidToGeocentric() {
super(3, 3, PARAMETERS);
complement = new EllipsoidToGeocentric(this);
}
/**
* Constructs a provider for the 2-dimensional case.
*
* @param complement The provider for the 3D case.
*/
private EllipsoidToGeocentric(final EllipsoidToGeocentric complement) {
super(2, 3, PARAMETERS);
this.complement = complement;
}
/**
* Returns the operation type.
*/
@Override
public Class getOperationType() {
return Conversion.class;
}
/**
* Returns {@code 2} if the given parameter group contains a {@linkplain #DIM} parameter
* having value 2. If the parameter value is 3 or if there is no parameter value, then
* this method returns {@code 3}, which is consistent with the default value.
*
* @throws InvalidParameterValueException if the dimension parameter has an invalid value.
*/
static int dimension(final ParameterValueGroup values) throws InvalidParameterValueException {
final Integer dimension = integerValue(DIM, values);
if (dimension != null) {
switch (dimension) {
case 2: // fall through;
case 3: return dimension;
default: {
final String name = DIM.getName().getCode();
throw new InvalidParameterValueException(Errors.format(Errors.Keys.
ILLEGAL_ARGUMENT_$2, name, dimension), name, dimension);
}
}
}
return 3;
}
/**
* Creates a transform from the specified group of parameter values.
*
* @param values The group of parameter values.
* @return The created math transform.
* @throws ParameterNotFoundException if a required parameter was not found.
*/
@Override
protected MathTransform createMathTransform(final ParameterValueGroup values)
throws ParameterNotFoundException
{
final double semiMajor = doubleValue(SEMI_MAJOR, values);
final double semiMinor = doubleValue(SEMI_MINOR, values);
final int dimension = dimension(values);
MathTransform transform = GeocentricTransform.create(semiMajor, semiMinor, SI.METRE, dimension != 2);
if (dimension != sourceDimension.intValue()) {
transform = new MathTransformDecorator(transform, complement);
}
return transform;
}
}