📄 concatenatedtransform.cs
字号:
// Copyright 2006 - Morten Nielsen (www.iter.dk)
//
// This file is part of SharpMap.
// SharpMap 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; either version 2 of the License, or
// (at your option) any later version.
//
// SharpMap 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.
// You should have received a copy of the GNU Lesser General Public License
// along with SharpMap; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
namespace SharpMap.CoordinateSystems.Transformations
{
internal class ConcatenatedTransform : MathTransform
{
protected IMathTransform _inverse;
public ConcatenatedTransform()
: this(new List<ICoordinateTransformation>())
{
}
public ConcatenatedTransform(List<ICoordinateTransformation> transformlist)
{
_CoordinateTransformationList = transformlist;
}
private List<ICoordinateTransformation> _CoordinateTransformationList;
public List<ICoordinateTransformation> CoordinateTransformationList
{
get { return _CoordinateTransformationList; }
set
{
_CoordinateTransformationList = value;
_inverse = null;
}
}
public override SharpMap.Geometries.Point Transform(SharpMap.Geometries.Point point)
{
if (point is SharpMap.Geometries.Point3D)
{
SharpMap.Geometries.Point pnt = (point as SharpMap.Geometries.Point3D).Clone();
foreach (ICoordinateTransformation ct in _CoordinateTransformationList)
pnt = ct.MathTransform.Transform(pnt);
return pnt;
}
else
{
SharpMap.Geometries.Point pnt = point.Clone();
foreach (ICoordinateTransformation ct in _CoordinateTransformationList)
pnt = ct.MathTransform.Transform(pnt);
return pnt;
}
}
public override Collection<SharpMap.Geometries.Point> TransformList(Collection<SharpMap.Geometries.Point> points)
{
Collection<SharpMap.Geometries.Point> pnts = new Collection<SharpMap.Geometries.Point>(points);
foreach (ICoordinateTransformation ct in _CoordinateTransformationList)
pnts = ct.MathTransform.TransformList(pnts);
return pnts;
}
/// <summary>
/// Returns the inverse of this conversion.
/// </summary>
/// <returns>IMathTransform that is the reverse of the current conversion.</returns>
public override IMathTransform Inverse()
{
if (_inverse == null)
{
_inverse = new ConcatenatedTransform(_CoordinateTransformationList);
_inverse.Invert();
}
return _inverse;
}
/// <summary>
/// Reverses the transformation
/// </summary>
public override void Invert()
{
_CoordinateTransformationList.Reverse();
foreach (ICoordinateTransformation ic in _CoordinateTransformationList)
ic.MathTransform.Invert();
}
public override string WKT
{
get { throw new Exception("The method or operation is not implemented."); }
}
public override string XML
{
get { throw new Exception("The method or operation is not implemented."); }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -