LambertConformal2SP changes for revisions 9356:10796

Those changes were applied to the LambertConformal class, but appear here as a side effect of SVN history. See LambertConformal for information on the actions taken.

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r9356:10796 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/projection/LambertConformal2SP.java
Revision 9356Revision 10796
/*
 * Geotools - OpenSource mapping toolkit
 * (C) 2003, 2004 Geotools Project Managment Committee (PMC)
 * (C) 2001, Institut de Recherche pour le Développement
 * (C) 1999, Fisheries and Oceans Canada
 *
 *    This library is free software; you can redistribute it and/or
/*
 * Geotools - OpenSource mapping toolkit
 * (C) 2003, 2004 Geotools Project Managment Committee (PMC)
 * (C) 2001, Institut de Recherche pour le D�veloppement
 * (C) 1999, Fisheries and Oceans Canada
 *
 *    This library is free software; you can redistribute it and/or
package org.geotools.referencing.operation.projection;

// J2SE dependencies and extensions
import java.util.Collection;
import java.awt.geom.Point2D;
import javax.units.NonSI;

// OpenGIS dependencies
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.referencing.operation.MathTransform;

// Geotools dependencies
import org.geotools.measure.Latitude;
import org.geotools.referencing.Identifier;
import org.geotools.metadata.citation.Citation;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.resources.cts.Resources;


/**
 * Lambert Conical Conformal Projection.  Areas and shapes are deformed
 * as one moves away from standard parallels.  The angles are true in
 * a limited area.  This projection is used for the charts of North America.
 * It uses a default central latitude of 40°N.
 * <br><br>
 *
 * This implementation provides transforms for three cases of the lambert conic
package org.geotools.referencing.operation.projection;

// J2SE dependencies and extensions
import java.awt.geom.Point2D;
import java.util.Collection;

import javax.units.NonSI;

import org.geotools.measure.Latitude;
import org.geotools.metadata.citation.Citation;
import org.geotools.referencing.Identifier;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.resources.cts.Resources;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.operation.MathTransform;


/**
 * Lambert Conical Conformal Projection.  Areas and shapes are deformed
 * as one moves away from standard parallels.  The angles are true in
 * a limited area.  This projection is used for the charts of North America.
 * It uses a default central latitude of 40�N.
 * <br><br>
 *
 * This implementation provides transforms for three cases of the lambert conic
*   <li><code>Lambert_Conformal_Conic_1SP</code> (EPSG code 9801)</li>
*   <li><code>Lambert_Conformal_Conic_2SP</code> (EPSG code 9802)</li>
*   <li><code>Lambert_Conic_Conformal_2SP_Belgium</code> (EPSG code 9803)</li>
* </ul>
*
* For the 1SP case the latitude of origin is used as the standard parallel (SP).
* To use a 1SP with a latitude of origin different from the SP, use the 2SP
* and set both the SP1 and SP2 to the single SP.
* <br><br>
*
* <strong>References:</strong><ul>
*   <li>John P. Snyder (Map Projections - A Working Manual,<br>
*       U.S. Geological Survey Professional Paper 1395, 1987)</li>
*   <li><code>Lambert_Conformal_Conic_1SP</code> (EPSG code 9801)</li>
*   <li><code>Lambert_Conformal_Conic_2SP</code> (EPSG code 9802)</li>
*   <li><code>Lambert_Conic_Conformal_2SP_Belgium</code> (EPSG code 9803)</li>
*   <li><code>Lambert_Conformal_Conic</code></li>
* </ul>
*
* For the 1SP case the latitude of origin is used as the standard parallel (SP).
* To use a 1SP with a latitude of origin different from the SP, use the 2SP
* and set both the SP1 and SP2 to the single SP. Alternatively, the "standard_parallel_2"
* parameter is optional and will be given the same value as "standard_parallel_1"
* if not set (creating a 1 standard parallel projection).
* <br><br>
*
* The <code>Lambert_Conformal_Conic</code> is a 2SP case that includes a
* scale_factor code that ESRI specifies.
* <br><br>
*
* <strong>References:</strong><ul>
*   <li>John P. Snyder (Map Projections - A Working Manual,<br>
*       U.S. Geological Survey Professional Paper 1395, 1987)</li>
* @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/lambert_conic_conformal_2sp_belgium.html">lambert_conic_conformal_2sp_belgium</A>
*
* @version $Id$
* @author André Gosselin
* @author Martin Desruisseaux
* @author Rueben Schulz
*/
* @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/lambert_conic_conformal_2sp_belgium.html">lambert_conic_conformal_2sp_belgium</A>
*
* @version $Id$
* @author Andr� Gosselin
* @author Martin Desruisseaux
* @author Rueben Schulz
*/
private static final double BELGE_A = 0.00014204313635987700;

/**
 * Standards parallels in radians, for {@link #getParameterValues} implementation.
 */
protected final double phi1, phi2;

/**
 * Internal variables for computation.
 */
private final double n,F,rho0;
private static final double BELGE_A = 0.00014204313635987700;

/**
 * Standards parallel 1 in radians, for {@link #getParameterValues} implementation.
 */
private final double phi1;

/**
 * Standards parallel 2 in radians, for {@link #getParameterValues} implementation.
 */
private double phi2;

/**
 * Internal variables for computation.
 */
private final double n,F,rho0;
 */
private final boolean belgium;


/**
 * The {@link org.geotools.referencing.operation.MathTransformProvider}
 */
private final boolean belgium;

/**
 * <code>true</code> for ESRI 2SP parameters.
 */
private final boolean esri;

/**
 * The {@link org.geotools.referencing.operation.MathTransformProvider}
            throws ParameterNotFoundException
    {
        final Collection descriptors = PARAMETERS.descriptors();
        return new LambertConformal(parameters, descriptors, false, false);
    }
}
            throws ParameterNotFoundException
    {
        final Collection descriptors = PARAMETERS.descriptors();
        return new LambertConformal(parameters, descriptors, false, false, false);
    }
}
public static class Provider2SP extends Provider {
    /**
     * The operation parameter descriptor for the {@link #phi1 standard parallel 1}
     * parameter value. Valid values range is from -90 to 90°. Default value is 0.
     */
    public static final ParameterDescriptor STANDARD_PARALLEL_1 = createDescriptor(
            new Identifier[] {
public static class Provider2SP extends Provider {
    /**
     * The operation parameter descriptor for the {@link #phi1 standard parallel 1}
     * parameter value. Valid values range is from -90 to 90�. Default value is 0.
     */
    public static final ParameterDescriptor STANDARD_PARALLEL_1 = createDescriptor(
            new Identifier[] {
/**
 * The operation parameter descriptor for the {@link #phi2 standard parallel 2}
 * parameter value. Valid values range is from -90 to 90°. Default value is 0.
 */
public static final ParameterDescriptor STANDARD_PARALLEL_2 = createDescriptor(
        new Identifier[] {
/**
 * The operation parameter descriptor for the {@link #phi2 standard parallel 2}
 * parameter value. Valid values range is from -90 to 90�. Default value is 0.
 */
public static final ParameterDescriptor STANDARD_PARALLEL_2 = createDescriptor(
        new Identifier[] {
            new Identifier(Citation.EPSG,     "Latitude of 2nd standard parallel"),
            new Identifier(Citation.GEOTIFF,  "StdParallel2")
        },
        0, -90, 90, NonSI.DEGREE_ANGLE);

/**
 * The parameters group.
 * @task REVISIT: ESRI also included the scale factor as a parameter
 */
static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new Identifier[] {
        new Identifier(Citation.OPEN_GIS, "Lambert_Conformal_Conic_2SP"),
            new Identifier(Citation.EPSG,     "Latitude of 2nd standard parallel"),
            new Identifier(Citation.GEOTIFF,  "StdParallel2")
        },
        Double.NaN, -90, 90, NonSI.DEGREE_ANGLE);

/**
 * The parameters group.
 */
static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new Identifier[] {
        new Identifier(Citation.OPEN_GIS, "Lambert_Conformal_Conic_2SP"),
    new Identifier(Citation.EPSG,     "9802"),
    new Identifier(Citation.GEOTIFF,  "CT_LambertConfConic_2SP"),
    new Identifier(Citation.GEOTIFF,  "CT_LambertConfConic"),
    new Identifier(Citation.ESRI,     "Lambert_Conformal_Conic"),
    new Identifier(Citation.GEOTOOLS, Resources.formatInternational(
                                      ResourceKeys.LAMBERT_CONFORMAL_PROJECTION))
}, new ParameterDescriptor[] {
    new Identifier(Citation.EPSG,     "9802"),
    new Identifier(Citation.GEOTIFF,  "CT_LambertConfConic_2SP"),
    new Identifier(Citation.GEOTIFF,  "CT_LambertConfConic"),
    new Identifier(Citation.GEOTOOLS, Resources.formatInternational(
                                      ResourceKeys.LAMBERT_CONFORMAL_PROJECTION))
}, new ParameterDescriptor[] {
           throws ParameterNotFoundException
   {
       final Collection descriptors = PARAMETERS.descriptors();
       return new LambertConformal(parameters, descriptors, true, false);
   }
}
           throws ParameterNotFoundException
   {
       final Collection descriptors = PARAMETERS.descriptors();
       return new LambertConformal(parameters, descriptors, true, false, false);
   }
}
            throws ParameterNotFoundException
    {
        final Collection descriptors = PARAMETERS.descriptors();
        return new LambertConformal(parameters, descriptors, true, true);
    }
}


/**
 * Construct a new map projection from the supplied parameters.
 *
 * @param  parameters The parameter values in standard units.
            throws ParameterNotFoundException
    {
        final Collection descriptors = PARAMETERS.descriptors();
        return new LambertConformal(parameters, descriptors, true, true, false);
    }
}

/**
 * The {@link org.geotools.referencing.operation.MathTransformProvider}
 * for a {@link LambertConformal} 2SP projection, using ESRI parameters.
 * ESRI includes a scale_factor parameter.
 *
 * @see org.geotools.referencing.operation.MathTransformFactory
 *
 * @version $Id$
 * @author Rueben Schulz
 */
 public static final class Provider2SP_ESRI extends Provider2SP {
    /**
     * The parameters group.
     */
    static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new Identifier[] {
            new Identifier(Citation.ESRI,     "Lambert_Conformal_Conic"),
            new Identifier(Citation.GEOTOOLS, Resources.formatInternational(
                                              ResourceKeys.LAMBERT_CONFORMAL_PROJECTION))
        }, new ParameterDescriptor[] {
            SEMI_MAJOR,          SEMI_MINOR,
            CENTRAL_MERIDIAN,    LATITUDE_OF_ORIGIN,
            STANDARD_PARALLEL_1, STANDARD_PARALLEL_2,
            SCALE_FACTOR,
            FALSE_EASTING,       FALSE_NORTHING
        });

/**
     * Construct a new provider.
     */
    public Provider2SP_ESRI() {
        super(PARAMETERS);
    }

    /**
     * Creates a transform from the specified group of parameter values.
     *
     * @param  parameters The group of parameter values.
     * @return The created math transform.
     * @throws ParameterNotFoundException if a required parameter was not found.
     */
    protected MathTransform createMathTransform(final ParameterValueGroup parameters)
            throws ParameterNotFoundException
    {
        final Collection descriptors = PARAMETERS.descriptors();
        return new LambertConformal(parameters, descriptors, true, false, true);
    }
}


/**
 * Construct a new map projection from the supplied parameters.
 *
 * @param  parameters The parameter values in standard units.
 * @param  sp2 <code>true</code> for 2SP, or <code>false</code> for 1SP.
 * @param  belgium <code>true</code> for the Belgium 2SP case.
 * @throws ParameterNotFoundException if a mandatory parameter is missing.
 *
 * @task REVISIT: set phi2 = phi1 if no SP2 value is given by user (an 1sp projection)
 */
public LambertConformal(final ParameterValueGroup parameters, final Collection expected,
                        final boolean sp2, final boolean belgium)
{
    //Fetch parameters
    super(parameters, expected);
    this.sp2         = sp2;
    this.belgium     = belgium;
    if (sp2) {
        phi1 = doubleValue(expected, Provider2SP.STANDARD_PARALLEL_1, parameters);
        phi2 = doubleValue(expected, Provider2SP.STANDARD_PARALLEL_2, parameters);
    } else {
        if (belgium) {
            throw new IllegalArgumentException();
 * @param  sp2 <code>true</code> for 2SP, or <code>false</code> for 1SP.
 * @param  belgium <code>true</code> for the Belgium 2SP case.
 * @throws ParameterNotFoundException if a mandatory parameter is missing.
 */
LambertConformal(final ParameterValueGroup parameters, final Collection expected,
                 final boolean sp2, final boolean belgium, final boolean esri)
        throws ParameterNotFoundException
{
    //Fetch parameters
    super(parameters, expected);
    this.sp2         = sp2;
    this.belgium     = belgium;
    this.esri        = esri;
    if (sp2) {
        phi1 = doubleValue(expected, Provider2SP.STANDARD_PARALLEL_1, parameters);
        ensureLatitudeInRange(Provider2SP.STANDARD_PARALLEL_1, phi1, true);
        phi2 = doubleValue(expected, Provider2SP.STANDARD_PARALLEL_2, parameters);
        if (Double.isNaN(phi2)) {
            phi2 = phi1;
        }
        ensureLatitudeInRange(Provider2SP.STANDARD_PARALLEL_2, phi2, true);
    } else {
        if (belgium) {
            throw new IllegalArgumentException();
 * {@inheritDoc}
 */
public ParameterDescriptorGroup getParameterDescriptors() {
    return (belgium) ?
                Provider2SP_Belgium.PARAMETERS :
                ((sp2) ? Provider2SP.PARAMETERS : Provider1SP.PARAMETERS);
}

/**
 * {@inheritDoc}
 */
public ParameterDescriptorGroup getParameterDescriptors() {
    return (esri) ?
                Provider2SP_ESRI.PARAMETERS :
                ((belgium) ?
                Provider2SP_Belgium.PARAMETERS :
                    ((sp2) ? Provider2SP.PARAMETERS : Provider1SP.PARAMETERS));
}

/**