001 //$HeadURL: $ 002 /*---------------------------------------------------------------------------- 003 This file is part of deegree, http://deegree.org/ 004 Copyright (C) 2001-2009 by: 005 Department of Geography, University of Bonn 006 and 007 lat/lon GmbH 008 009 This library is free software; you can redistribute it and/or modify it under 010 the terms of the GNU Lesser General Public License as published by the Free 011 Software Foundation; either version 2.1 of the License, or (at your option) 012 any later version. 013 This library is distributed in the hope that it will be useful, but WITHOUT 014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 016 details. 017 You should have received a copy of the GNU Lesser General Public License 018 along with this library; if not, write to the Free Software Foundation, Inc., 019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 020 021 Contact information: 022 023 lat/lon GmbH 024 Aennchenstr. 19, 53177 Bonn 025 Germany 026 http://lat-lon.de/ 027 028 Department of Geography, University of Bonn 029 Prof. Dr. Klaus Greve 030 Postfach 1147, 53001 Bonn 031 Germany 032 http://www.geographie.uni-bonn.de/deegree/ 033 034 e-mail: info@deegree.org 035 ----------------------------------------------------------------------------*/ 036 037 package org.deegree.crs.transformations.polynomial; 038 039 import java.util.List; 040 041 import javax.vecmath.Point3d; 042 043 import org.deegree.crs.Identifiable; 044 import org.deegree.crs.coordinatesystems.CoordinateSystem; 045 import org.deegree.crs.exceptions.TransformationException; 046 import org.deegree.crs.transformations.Transformation; 047 import org.deegree.framework.log.ILogger; 048 import org.deegree.framework.log.LoggerFactory; 049 050 /** 051 * <code>PolynomialTransformation</code> is the base class for all polynomial transformations. 052 * 053 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a> 054 * 055 * @author last edited by: $Author$ 056 * 057 * @version $Revision$, $Date$ 058 * 059 */ 060 public abstract class PolynomialTransformation extends Transformation { 061 062 private static final long serialVersionUID = -393518250583955870L; 063 064 private static ILogger LOG = LoggerFactory.getLogger( PolynomialTransformation.class ); 065 066 private List<Double> firstParams; 067 068 private List<Double> secondParams; 069 070 /** 071 * @param firstParameters 072 * the parameters for the 073 * @param secondParameters 074 * @param sourceCRS 075 * @param targetCRS 076 * @param id 077 * an identifiable instance containing information about this transformation 078 */ 079 public PolynomialTransformation( List<Double> firstParameters, List<Double> secondParameters, 080 CoordinateSystem sourceCRS, CoordinateSystem targetCRS, Identifiable id ) { 081 super( sourceCRS, targetCRS, id ); 082 if ( firstParameters == null ) { 083 throw new IllegalArgumentException( "The first parameter list my not be null" ); 084 } 085 this.firstParams = firstParameters; 086 087 if ( secondParameters == null ) { 088 throw new IllegalArgumentException( "The second parameter list my not be null" ); 089 } 090 this.secondParams = secondParameters; 091 092 } 093 094 /** 095 * @return the order of the Polynomial used for this transformation. 096 */ 097 public abstract int getOrder(); 098 099 /** 100 * @param originalPoints 101 * of the projection 102 * @param projectedPoints 103 * the 'function' values 104 * @param polynomalOrder 105 * the order of the polynomial function to use. 106 * @return the variables the polynomial used for this transformation. 107 */ 108 public abstract float[][] createVariables( List<Point3d> originalPoints, List<Point3d> projectedPoints, 109 int polynomalOrder ); 110 111 /** 112 * The central method, which actually transforms the points by applying the implemented polynomial. 113 * 114 * @param srcPoints 115 * to transform 116 * @return the transformed points. 117 * @throws TransformationException 118 * if for some reason one of the incoming points could not be transformed. 119 */ 120 public abstract List<Point3d> applyPolynomial( List<Point3d> srcPoints ) 121 throws TransformationException; 122 123 /** 124 * @return the Parameters for the calculation of the first coordinate. 125 */ 126 public List<Double> getFirstParams() { 127 return firstParams; 128 } 129 130 /** 131 * @return the Parameters for the calculation of the second coordinate. 132 */ 133 public List<Double> getSecondParams() { 134 return secondParams; 135 } 136 137 @Override 138 public final List<Point3d> doTransform( List<Point3d> srcPts ) 139 throws TransformationException { 140 return applyPolynomial( srcPts ); 141 } 142 143 @Override 144 public void inverse() { 145 LOG.logWarning( "A Polynomial Transformation cannot be inverse yet" ); 146 } 147 148 @Override 149 public boolean isIdentity() { 150 return false; 151 } 152 153 @Override 154 public boolean isInverseTransform() { 155 return false; 156 } 157 158 }