├── .github
└── workflows
│ ├── CI build.yml
│ ├── CI release.yml
│ └── CI snapshot.yml
├── .gitignore
├── LICENSE.md
├── codecov.yml
├── docs
├── CHANGELOG.md
├── HEADER.md
└── README.md
├── grids
├── RAC09.txt
├── RAF09.txt
├── RAR07.mnt
├── egm08fr.mnt
├── gg10_gtbt.mnt
├── gg10_ld.mnt
├── gg10_ls.mnt
├── gg10_mart.mnt
├── gg10_mg.mnt
├── gg10_sb.mnt
├── gg10_sm.mnt
├── ggg00.txt
├── ggg00_ld.txt
├── ggg00_ls.txt
├── ggg00_mg.txt
├── ggg00_sb.txt
├── ggg00_sm.txt
├── ggguy00.txt
├── ggker08v2.txt
├── ggm00.txt
├── ggm04v1.txt
├── ggpf02-Bora.mnt
├── ggpf02-Huahine.mnt
├── ggpf02-Maiao.mnt
├── ggpf02-Maupiti.mnt
├── ggpf02-Raiatea.mnt
├── ggpf02-Tahaa.mnt
├── ggpf02-Tupai.mnt
├── ggpf05-HivaOa.mnt
├── ggpf05-Nuku.mnt
├── ggpf08-Fakarava.mnt
├── ggpf08-Gambier.mnt
├── ggpf08-Hao.mnt
├── ggpf08-Mataiva.mnt
├── ggpf08-Raivavae.mnt
├── ggpf08-Reao.mnt
├── ggpf08-Rurutu.mnt
├── ggpf08-Tikehau.mnt
├── ggpf08-Tubuai.mnt
├── ggpf10-Moorea.mnt
├── ggpf10-Tahiti.mnt
├── ggspm06v1.txt
├── gr3df97a.txt
└── ntf_r93.gsb
├── pom.xml
└── src
├── main
├── java
│ └── org
│ │ └── cts
│ │ ├── CRSFactory.java
│ │ ├── CRSHelper.java
│ │ ├── CoordinateDimensionException.java
│ │ ├── Identifiable.java
│ │ ├── IdentifiableComponent.java
│ │ ├── Identifier.java
│ │ ├── IllegalCoordinateException.java
│ │ ├── Parameter.java
│ │ ├── crs
│ │ ├── CRSException.java
│ │ ├── CompoundCRS.java
│ │ ├── CoordinateReferenceSystem.java
│ │ ├── GeocentricCRS.java
│ │ ├── GeodeticCRS.java
│ │ ├── Geographic2DCRS.java
│ │ ├── Geographic3DCRS.java
│ │ ├── ProjectedCRS.java
│ │ └── VerticalCRS.java
│ │ ├── cs
│ │ ├── Axis.java
│ │ ├── CoordinateSystem.java
│ │ ├── Extent.java
│ │ ├── GeographicExtent.java
│ │ └── OutOfExtentException.java
│ │ ├── datum
│ │ ├── AbstractDatum.java
│ │ ├── Datum.java
│ │ ├── Ellipsoid.java
│ │ ├── GeodeticDatum.java
│ │ ├── PrimeMeridian.java
│ │ └── VerticalDatum.java
│ │ ├── op
│ │ ├── AbstractCoordinateOperation.java
│ │ ├── ChangeCoordinateDimension.java
│ │ ├── CoordinateOperation.java
│ │ ├── CoordinateOperationException.java
│ │ ├── CoordinateOperationFactory.java
│ │ ├── CoordinateOperationNotFoundException.java
│ │ ├── CoordinateOperationSequence.java
│ │ ├── CoordinateRounding.java
│ │ ├── CoordinateSwitch.java
│ │ ├── Geocentric2Geographic.java
│ │ ├── Geographic2Geocentric.java
│ │ ├── Identity.java
│ │ ├── IterativeTransformation.java
│ │ ├── LoadMemorizeCoordinate.java
│ │ ├── LongitudeRotation.java
│ │ ├── MemorizeCoordinate.java
│ │ ├── NonInvertibleOperationException.java
│ │ ├── OppositeCoordinate.java
│ │ ├── TooManyIterationsException.java
│ │ ├── UnitConversion.java
│ │ ├── projection
│ │ │ ├── AlbersEqualArea.java
│ │ │ ├── CassiniSoldner.java
│ │ │ ├── CylindricalEqualArea.java
│ │ │ ├── EquidistantCylindrical.java
│ │ │ ├── GaussSchreiberTransverseMercator.java
│ │ │ ├── Krovak.java
│ │ │ ├── LambertAzimuthalEqualArea.java
│ │ │ ├── LambertConicConformal1SP.java
│ │ │ ├── LambertConicConformal2SP.java
│ │ │ ├── Mercator1SP.java
│ │ │ ├── MillerCylindrical.java
│ │ │ ├── NewZealandMapGrid.java
│ │ │ ├── ObliqueMercator.java
│ │ │ ├── ObliqueStereographicAlternative.java
│ │ │ ├── Polyconic.java
│ │ │ ├── Projection.java
│ │ │ ├── Stereographic.java
│ │ │ ├── SwissObliqueMercator.java
│ │ │ ├── TransverseMercator.java
│ │ │ ├── UniversalTransverseMercator.java
│ │ │ └── UniversalTransverseMercatorAuto.java
│ │ └── transformation
│ │ │ ├── Altitude2EllipsoidalHeight.java
│ │ │ ├── FrenchGeocentricNTF2RGF.java
│ │ │ ├── GeoTransformation.java
│ │ │ ├── GeocentricTransformation.java
│ │ │ ├── GeocentricTransformationSequence.java
│ │ │ ├── GeocentricTranslation.java
│ │ │ ├── GridBasedTransformation.java
│ │ │ ├── NTv2GridShiftTransformation.java
│ │ │ ├── ParamBasedTransformation.java
│ │ │ ├── SevenParameterTransformation.java
│ │ │ ├── grid
│ │ │ ├── GridShift.java
│ │ │ ├── GridShiftFile.java
│ │ │ ├── SubGrid.java
│ │ │ └── Util.java
│ │ │ └── grids
│ │ │ ├── BleggGeographicGrid.java
│ │ │ ├── GeographicGrid.java
│ │ │ ├── Grid.java
│ │ │ ├── GridUtils.java
│ │ │ ├── IGNGeographicGrid.java
│ │ │ ├── IGNVerticalGrid.java
│ │ │ └── InterpolationMethodException.java
│ │ ├── parser
│ │ ├── prj
│ │ │ ├── AbstractPrjElement.java
│ │ │ ├── PrjElement.java
│ │ │ ├── PrjKeyParameters.java
│ │ │ ├── PrjMatcher.java
│ │ │ ├── PrjNodeElement.java
│ │ │ ├── PrjNodeMatcher.java
│ │ │ ├── PrjNumberElement.java
│ │ │ ├── PrjParser.java
│ │ │ ├── PrjParserException.java
│ │ │ ├── PrjStringElement.java
│ │ │ ├── PrjValueParameters.java
│ │ │ └── PrjWriter.java
│ │ ├── proj
│ │ │ ├── ParameterException.java
│ │ │ ├── ProjKeyParameters.java
│ │ │ ├── ProjParser.java
│ │ │ └── ProjValueParameters.java
│ │ └── proj4
│ │ │ └── Proj4Parser.java
│ │ ├── registry
│ │ ├── AbstractProjRegistry.java
│ │ ├── EPSGRegistry.java
│ │ ├── ESRIRegistry.java
│ │ ├── IGNFRegistry.java
│ │ ├── Nad27Registry.java
│ │ ├── Nad83Registry.java
│ │ ├── Registry.java
│ │ ├── RegistryException.java
│ │ ├── RegistryManager.java
│ │ ├── RegistryManagerListener.java
│ │ └── WorldRegistry.java
│ │ ├── units
│ │ ├── Measure.java
│ │ ├── Quantity.java
│ │ └── Unit.java
│ │ └── util
│ │ ├── AngleFormat.java
│ │ ├── Complex.java
│ │ └── UTMUtils.java
└── resources
│ └── org
│ └── cts
│ ├── log4j.properties
│ └── registry
│ ├── epsg
│ ├── esri
│ ├── ignf
│ ├── nad27
│ ├── nad83
│ └── world
└── test
├── java
└── org
│ └── cts
│ ├── CRSFactoryTest.java
│ ├── CRSHelperTest.java
│ ├── CRSIdentifierTest.java
│ ├── CTSTestCase.java
│ ├── TestUtils.java
│ ├── cs
│ └── GeographicextentTest.java
│ ├── datum
│ ├── EllipsoidTest.java
│ ├── GeodeticDatumTest.java
│ ├── NoRecursionTest.java
│ └── TestPrimeMeridian.java
│ ├── op
│ ├── BaseCoordinateTransformTest.java
│ ├── BatchCoordinateTransformTest.java
│ ├── CirceAntilleGuyaneComplianceTest.java
│ ├── CirceMayotteComplianceTest.java
│ ├── CirceMetropoleComplianceTest.java
│ ├── CirceNouvelleCaledonieTest.java
│ ├── CirceReunionComplianceTest.java
│ ├── EPSGTransformTest.java
│ ├── FrenchGridsTest.java
│ ├── FrenchProjectionsRobustnessTest.java
│ ├── PRJCoordinateTransformationTest.java
│ ├── SpecialCoordinateTransformTest.java
│ ├── UserDefinedTransform.java
│ ├── VerticalTransformTest.java
│ ├── projection
│ │ ├── ProjectionTest.java
│ │ └── TransverseMercatorTest.java
│ └── transformation
│ │ └── SevenParameterTransformationTest.java
│ ├── parser
│ ├── prj
│ │ ├── IOPrjTest.java
│ │ ├── PrjParserTest.java
│ │ ├── PrjWriterTest.java
│ │ └── Ticket98Test.java
│ └── proj4
│ │ └── Proj4ParserTest.java
│ ├── registry
│ └── RegistryParserTest.java
│ └── util
│ ├── AngleFormatTest.java
│ ├── ComplexTest.java
│ └── UTMUtilsTest.java
└── resources
└── org
└── cts
├── op
├── crstransform.csv
└── frenchgridstest.csv
└── parser
└── prj
├── NTF_Lambert_II_etendu.prj
└── WaukeeStreets.prj
/.github/workflows/CI build.yml:
--------------------------------------------------------------------------------
1 | name: CI build
2 |
3 | on:
4 | pull_request:
5 | branches: [ '**' ]
6 | workflow_run:
7 | workflows: ["CI release"]
8 | branches: [ '**' ]
9 | types:
10 | - completed
11 | workflow_dispatch:
12 |
13 | jobs:
14 | build:
15 | # Main build job used to
16 | name: Build
17 | runs-on: ubuntu-latest
18 | steps:
19 | # Checkout the source code of the project
20 | - name: Checkout
21 | uses: actions/checkout@v2
22 |
23 | # Set up the jdk using version 11 of Adoptium Temurin
24 | - name: Setup java 11 using Adoptium Temurin
25 | uses: actions/setup-java@v2
26 | with:
27 | distribution: 'temurin'
28 | java-version: '11'
29 |
30 | # Build the project using
31 | # - clean : clean up the workspace
32 | # - validate : perform different check like the dependency and plugin version update
33 | # - compile : compile the source code.
34 | # - test : Perform the tests.
35 | - name: Build
36 | run: mvn -ntp clean validate compile test javadoc:test-javadoc javadoc:jar
37 |
38 | # Check changelog update
39 | - name: Check changelog update
40 | uses: dorny/paths-filter@v2
41 | id: changes
42 | with:
43 | filters: |
44 | changelog:
45 | - 'docs/CHANGELOG.md'
46 | sources:
47 | - '**/pom.xml'
48 | - '**/README.md'
49 | - '**/src/**'
50 | if: github.event_name != 'workflow_dispatch'
51 |
52 | - if: steps.changes.outputs.changelog == 'false' && github.event_name != 'workflow_dispatch' && steps.changes.outputs.sources == 'true'
53 | run: |
54 | echo "Please update the Changelog.md file."
55 | exit 1
56 |
--------------------------------------------------------------------------------
/.github/workflows/CI release.yml:
--------------------------------------------------------------------------------
1 | name: CI release
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | nextVersion:
7 | required: false
8 | description: "Next version (optional)"
9 |
10 | jobs:
11 | build:
12 | name: Release and next iteration
13 | runs-on: ubuntu-latest
14 | steps:
15 | # Checkout the source code of the project
16 | - name: Checkout
17 | uses: actions/checkout@v2
18 |
19 | # Install the GPG secret key
20 | - name: Step 2 - Import GPG Key
21 | run: |
22 | echo "${{ secrets.GPG_PUBLIC_KEY }}" | gpg --import
23 | echo "${{ secrets.GPG_SECRET_KEY }}" | gpg --import --no-tty --batch --yes
24 | env:
25 | GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
26 | GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
27 |
28 | # Set up the jdk using version 11 of Adoptium Temurin
29 | - name: Setup java 11 using Adoptium Temurin
30 | uses: actions/setup-java@v2
31 | with:
32 | distribution: 'temurin'
33 | java-version: '11'
34 | server-id: ossrh
35 | server-username: MAVEN_USERNAME
36 | server-password: MAVEN_PASSWORD
37 | gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
38 | gpg-passphrase: MAVEN_GPG_PASSPHRASE
39 |
40 | # Configure git user in order to sign release with OrbisGIS user.
41 | - name: Configure Git User
42 | run: |
43 | git config user.email "info@orbisgis.org"
44 | git config user.name OrbisGIS
45 |
46 |
47 | # Test build
48 | - name: Build test
49 | run: mvn -ntp clean validate compile test javadoc:test-javadoc javadoc:jar
50 |
51 | # Create the release :
52 | # - move from Snapshot version to Release
53 | # - commit and tag release
54 | # - move to next Snapshot
55 | # - upload release to maven repo
56 | - name: Release
57 | run: |
58 | VERSION=${{ github.event.inputs.nextVersion }}
59 | mvn \
60 | -ntp \
61 | --batch-mode \
62 | -P deploy \
63 | -Dmaven.test.skip=true \
64 | release:prepare release:perform \
65 | -Dusername=$GITHUB_ACTOR -Dpassword=$GITHUB_TOKEN ${VERSION:+"-DdevelopmentVersion="$VERSION"-SNAPSHOT"}
66 | env:
67 | MAVEN_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
68 | MAVEN_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}
69 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
70 |
71 | # Export the last git tag into env.
72 | - name: Export env values
73 | run: echo "GIT_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
74 |
75 | # Make the github release from the last created tag. Write in its body the content of the changelog file.
76 | - name: Make github release
77 | uses: actions/create-release@v1
78 | env:
79 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
80 | with:
81 | tag_name: ${{ env.GIT_TAG }}
82 | release_name: ${{ env.GIT_TAG }}
83 | body_path: docs/CHANGELOG.md
84 | draft: false
85 | prerelease: false
86 |
87 | # Clear the changelog file and add its header
88 | - name: Clear changelog
89 | run: |
90 | echo "## Changelog for v$( mvn help:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }' | cut -d- -f1)" > docs/CHANGELOG.md
91 | git commit -a -m "Empty changelog."
92 | git push origin master
93 |
94 | # If the version change is a major or minor, create a branch from the previous tag for future revisions.
95 | - name: Branch fork
96 | run: |
97 | GIT_TAG="${GIT_TAG:1}"
98 | CUR_TAG="$( mvn help:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }' | cut -d- -f1)"
99 | SPLIT0=(${GIT_TAG//./ })
100 | SPLIT1=(${CUR_TAG//./ })
101 | if [ "${SPLIT0[0]}" = "${SPLIT1[0]}" ] && [ "${SPLIT0[1]}" = "${SPLIT1[1]}" ]; then
102 | echo "Revision change"
103 | else
104 | echo "Minor or Major change"
105 | BRANCH="${SPLIT0[0]}.${SPLIT0[1]}.X"
106 | git checkout -b "$BRANCH" "v${GIT_TAG}"
107 | mvn versions:set -DnewVersion="${SPLIT0[0]}.${SPLIT0[1]}.$((${SPLIT0[2]}+1))-SNAPSHOT"
108 | git commit -a -m "Set next version."
109 | git push -u origin "$BRANCH"
110 | fi
111 |
--------------------------------------------------------------------------------
/.github/workflows/CI snapshot.yml:
--------------------------------------------------------------------------------
1 | name: CI snapshot
2 |
3 | on:
4 | push:
5 | branches: [ '**' ]
6 | workflow_run:
7 | workflows: ["CI release"]
8 | branches: [ '**' ]
9 | types:
10 | - completed
11 | workflow_dispatch:
12 |
13 | jobs:
14 | build:
15 | name: Upload Snapshot
16 | runs-on: ubuntu-latest
17 | steps:
18 | # Checkout the source code of the project
19 | - name: Checkout
20 | uses: actions/checkout@v2
21 |
22 | # Install the GPG secret key
23 | - name: Step 2 - Import GPG Key
24 | run: |
25 | echo "${{ secrets.GPG_PUBLIC_KEY }}" | gpg --import
26 | echo "${{ secrets.GPG_SECRET_KEY }}" | gpg --import --no-tty --batch --yes
27 | env:
28 | GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
29 | GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
30 |
31 | # Set up the jdk using version 11 of Adoptium Temurin
32 | - name: Setup java 11 using Adoptium Temurin
33 | uses: actions/setup-java@v2
34 | with:
35 | distribution: 'temurin'
36 | java-version: '11'
37 | server-id: ossrh
38 | server-username: MAVEN_USERNAME
39 | server-password: MAVEN_PASSWORD
40 | gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
41 | gpg-passphrase: MAVEN_GPG_PASSPHRASE
42 |
43 | # Deploy the snapshot
44 | - name: Deploy
45 | run: mvn deploy -ntp --batch-mode
46 | env:
47 | MAVEN_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
48 | MAVEN_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}
49 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
50 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | *.iml
3 | .idea
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: off
--------------------------------------------------------------------------------
/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Changelog for v1.7.2
2 |
3 | - Use junit-jupiter-api in test scope only #160
4 | - Remove unnecessary logger
5 | - Update github actions
6 |
--------------------------------------------------------------------------------
/docs/HEADER.md:
--------------------------------------------------------------------------------
1 | Coordinate Transformations Suite (abridged CTS) is a library developped to
2 | perform Coordinate Transformations using well known geodetic algorithms
3 | and parameter sets.
4 | Its main focus are simplicity, flexibility, interoperability, in this order.
5 |
6 | This library has been originally developed by Michaël Michaud under the JGeod
7 | name. It has been renamed CTS in 2009 and shared to the community from
8 | the OrbisGIS code repository.
9 |
10 | CTS is free software: you can redistribute it and/or modify it under the
11 | terms of the GNU Lesser General Public License as published by the Free Software
12 | Foundation, either version 3 of the License.
13 |
14 | CTS is distributed in the hope that it will be useful, but WITHOUT ANY
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 | A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public License along with
19 | CTS. If not, see
A point in the real world may have different coordinates, depending on
35 | * the CoordinateReferenceSystem
used. The different types of
36 | * CoordinateReferenceSystem defined by EPSG
37 | * are :
CoordinateReferenceSystem
.
70 | *
71 | * @return
72 | */
73 | public CoordinateSystem getCoordinateSystem();
74 |
75 | /**
76 | * Returns the {@link Datum} to which this
77 | * CoordinateReferenceSystem
is refering. For compound
78 | * CoordinateReferenceSystem
, getDatum returns the the main
79 | * datum, ie the {@link org.cts.datum.GeodeticDatum} (or horizontal Datum).
80 | *
81 | * @return
82 | */
83 | public Datum getDatum();
84 |
85 | /**
86 | * Returns the {@link Projection} to which this
87 | * CoordinateReferenceSystem
is refering. It returns null if no
88 | * projection is defined for this CRS.
89 | *
90 | * @return
91 | */
92 | public Projection getProjection();
93 |
94 | /**
95 | * Returns a WKT representation of the CoordinateReferenceSystem.
96 | *
97 | * @return
98 | */
99 | public String toWKT();
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/cs/Extent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see Extent
defines a part of an infinite n-dimension space thanks to
29 | * a method returning true for any set of coordinates lying inside this part and
30 | * false for coordinates lying outside (input coordinates must be an array of n
31 | * doubles).
32 | *
33 | * @author Michaël Michaud
34 | */
35 | public interface Extent {
36 |
37 | /**
38 | * Return the name of this extent.
39 | */
40 | public String getName();
41 |
42 | /**
43 | * Return wether coord is inside this Extent or not. It's up to the user to
44 | * check consistency between coord and extent type.
45 | */
46 | public boolean isInside(double[] coord);
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/cs/OutOfExtentException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see
32 | * In surveying and geodesy, a datum is a reference point on the earth's surface
33 | * against which position measurements are made, and an associated model of the
34 | * shape of the earth for computing positions. Horizontal datums are used for
35 | * describing a point on the earth's surface, in latitude and longitude or
36 | * another coordinate system. Vertical datums are used to measure elevations or
37 | * underwater depths. In engineering and drafting, a datum is a reference point,
38 | * surface, or axis on an object against which measurements are made.
39 | * (Taken from wikipedia on
40 | * 2006-10-06)
41 | *
42 | * @author Michaël Michaud
43 | */
44 | public interface Datum extends Identifiable {
45 |
46 | /**
47 | * Returns origin description of this Datum.
48 | */
49 | public String getOrigin();
50 |
51 | /**
52 | * Returns the valid extent of this Datum.
53 | */
54 | public Extent getExtent();
55 |
56 | /**
57 | * Returns the realization epoch as a String.
58 | */
59 | public String getEpoch();
60 |
61 | /**
62 | * Returns the ellipsoid of this datum.
63 | */
64 | public Ellipsoid getEllipsoid();
65 |
66 | /**
67 | * Returns the ellipsoid of this datum.
68 | */
69 | public CoordinateOperation getToWGS84();
70 |
71 | /**
72 | * Returns the primemeridian of this datum.
73 | */
74 | public PrimeMeridian getPrimeMeridian();
75 | }
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/AbstractCoordinateOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see coord
is not
58 | * compatible with this CoordinateOperation
.
59 | * @throws org.cts.op.CoordinateOperationException if this operation
60 | * failed during the transformation process.
61 | */
62 | public abstract double[] transform(double[] coord)
63 | throws IllegalCoordinateException, CoordinateOperationException;
64 |
65 | /**
66 | * Creates the inverse CoordinateOperation. This method can be used to chain
67 | * {@link org.cts.op.CoordinateOperation}s and/or inverse CoordinateOperation in
68 | * a unique CoordinateOperationSequence. This method is not declared
69 | * abstract, so that implementation classes have not to implement it if they
70 | * represent non invertible operation.
71 | */
72 | public CoordinateOperation inverse()
73 | throws NonInvertibleOperationException {
74 | throw new NonInvertibleOperationException(this.toString()
75 | + " is non invertible");
76 | }
77 |
78 | /**
79 | * Returns the precision of the transformation.
Precision is a double 80 | * representing the mean error, in meters made on the position resulting 81 | * from this {@link org.cts.op.CoordinateOperation}.
ex. : 0.001 means that 82 | * the precision of the resulting position is about one millimeter
83 | * Default precision (or maximum precision) is considered to be equals to
84 | * 1E-9 which is the value of an ulp (units in the last place) for a double
85 | * value equals to 6378137.0 (Earth semi-major axis).
86 | */
87 | public double getPrecision() {
88 | return precision;
89 | }
90 |
91 |
92 | /**
93 | * @return true if this operation does not change coordinates.
94 | */
95 | public boolean isIdentity() {
96 | return false;
97 | }
98 | }
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/ChangeCoordinateDimension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see
31 | * This is the main interface used to implement geodetic algorithms and perform 32 | * coordinate conversions or coordinate transformations from one 33 | * {@link org.cts.crs.CoordinateReferenceSystem} to another. 34 | * 35 | * @author Michaël Michaud 36 | */ 37 | public interface CoordinateOperation extends Identifiable { 38 | 39 | /** 40 | * Transform values of a double array.
WARNING : In the general
41 | * case, double values of the coord parameter are changed without the
42 | * creation of a new array. In some cases (when the returned array must have
43 | * a different length, a new double array is created and returned.
44 | *
45 | * @param coord coordinate to be transformed
46 | * @return the same object with new values or a new double array
47 | * @throws IllegalCoordinateException if coord
is not
48 | * compatible with this CoordinateOperation
.
49 | * @throws org.cts.op.CoordinateOperationException if this operation
50 | * failed during the transformation process.
51 | */
52 | public double[] transform(double[] coord) throws IllegalCoordinateException, CoordinateOperationException;
53 |
54 | /**
55 | * Return the inverse CoordinateOperation, or throw a
56 | * NonInvertibleOperationException. If op.inverse() is not null,
57 | *
58 | * op.inverse().transform(op.transform(point)); 59 | *should let point unchanged. 60 | */ 61 | public CoordinateOperation inverse() throws NonInvertibleOperationException; 62 | 63 | /** 64 | * Return the precision of the transformation.
Precision is a double
65 | * representing the mean error, in meters made on the position resulting
66 | * from this
67 | * CoordinateOperation
.
ex. : 0.001 means that the precision 68 | * of the resulting position is about one millimeter
Default precision
69 | * (or maximum precision) is considered to be equals to 1E-9 which is the
70 | * value of an ulp (units in the last place) for a double value equals to
71 | * 6378137.0 (Earth semi-major axis).
72 | */
73 | public double getPrecision();
74 |
75 | /**
76 | * @return true if this operation does not change coordinates.
77 | */
78 | public boolean isIdentity();
79 | }
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/CoordinateOperationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see coord
is not
87 | * compatible with this CoordinateOperation
.
88 | */
89 | @Override
90 | public double[] transform(double[] coord) throws IllegalCoordinateException {
91 | if (coord == null || coord.length == 0) {
92 | throw new CoordinateDimensionException(Arrays.toString(coord)
93 | + " is an invalid coordinate");
94 | }
95 | for (int i = 0; i < coord.length; i++) {
96 | if (Double.isNaN(coord[i])) {
97 | continue;
98 | }
99 | coord[i] = Math.rint(coord[i] * inv_resolution) / inv_resolution;
100 | }
101 | return coord;
102 | }
103 |
104 | /**
105 | * Creates a coordinate rounding operation from a decimal place number.
106 | *
107 | * @param decimalPlaces number of decimal places
108 | */
109 | public static CoordinateRounding createCoordinateRoundingOperationFromDecimalPlaces(int decimalPlaces) {
110 | double u = 1.0;
111 | for (int i = 0; i < decimalPlaces; i++) {
112 | u *= 10.0;
113 | }
114 | return new CoordinateRounding(1.0 / u);
115 | }
116 |
117 | /**
118 | * Creates a coordinate rounding operation from the smallest representable
119 | * value.
120 | *
121 | * @param resolution smallest representable value
122 | */
123 | public static CoordinateRounding createCoordinateRoundingOperation(double resolution) {
124 | return new CoordinateRounding(resolution);
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/CoordinateSwitch.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see coord
is not
52 | * compatible with this CoordinateOperation
.
53 | */
54 | @Override
55 | public double[] transform(double[] coord)
56 | throws IllegalCoordinateException {
57 | if (coord.length < Math.min(pos1, pos2)) {
58 | throw new CoordinateDimensionException(coord, Math.max(pos1, pos2));
59 | }
60 | double d1 = coord[pos1];
61 | coord[pos1] = coord[pos2];
62 | coord[pos2] = d1;
63 | return coord;
64 | }
65 |
66 | /**
67 | * Creates the inverse CoordinateOperation.
68 | */
69 | @Override
70 | public CoordinateOperation inverse() {
71 | return this;
72 | }
73 |
74 | /**
75 | * Creates a new operation to switch coord pos1 and coord pos2.
76 | *
77 | * @param pos1 position of the ordinate to switch to pos2
78 | * @param pos2 position of the ordinate to switch to pos1
79 | */
80 | public CoordinateSwitch(int pos1, int pos2) {
81 | super(new Identifier(CoordinateOperation.class, "Coordinates switch"));
82 | this.pos1 = pos1;
83 | this.pos2 = pos2;
84 | }
85 |
86 | /**
87 | * Returns true if o is equals to this
operation.
88 | *
89 | * @param o The object to compare to
90 | */
91 | @Override
92 | public boolean equals(Object o) {
93 | if (this == o) return true;
94 | return o instanceof CoordinateSwitch &&
95 | pos1 == ((CoordinateSwitch) o).pos1 &&
96 | pos2 == ((CoordinateSwitch) o).pos2;
97 | }
98 | }
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/Identity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see
This transformation doesn't do anything.
33 | *
34 | * @author Michaël Michaud
35 | */
36 | public class Identity extends AbstractCoordinateOperation implements ParamBasedTransformation, GeocentricTransformation {
37 |
38 | /**
39 | * The identity transformation. When used to transform coordinates, it
40 | * returns the input coordinates.
41 | */
42 | public static final Identity IDENTITY = new Identity();
43 |
44 | /**
45 | * Identity is defined as a Singleton in order to avoid unuseful object
46 | * creation.
47 | */
48 | private Identity() {
49 | super(new Identifier(CoordinateOperation.class, "Identity"));
50 | this.precision = 0.0;
51 | }
52 |
53 | /**
54 | * Apply the identity transformation to input coordinates.
55 | *
56 | * @param coord is an array containing one, two or three ordinates
57 | */
58 | @Override
59 | public double[] transform(double[] coord) {
60 | return coord;
61 | }
62 |
63 | /**
64 | * Creates the inverse CoordinateOperation.
65 | */
66 | @Override
67 | public GeocentricTransformation inverse() {
68 | return this;
69 | }
70 |
71 | /**
72 | * Returns true if o is also an Identity CoordinateOperation.
73 | *
74 | * @param o The object to compare this ProjectedCRS against
75 | */
76 | @Override
77 | public boolean equals(Object o) {
78 | if (this == o) {
79 | return true;
80 | }
81 | if (o instanceof CoordinateOperation) {
82 | return ((CoordinateOperation) o).isIdentity();
83 | }
84 | return false;
85 | }
86 |
87 | /**
88 | * Returns 0 for all identity operations.
89 | */
90 | @Override
91 | public int hashCode() {
92 | return 0;
93 | }
94 |
95 | /**
96 | * @return true if this operation does not change coordinates.
97 | */
98 | public boolean isIdentity() {
99 | return true;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/IterativeTransformation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see coord
is not
64 | * compatible with this CoordinateOperation
.
65 | */
66 | @Override
67 | public double[] transform(double[] coord) throws IllegalCoordinateException {
68 | if (coord.length < 4) {
69 | throw new IllegalCoordinateException("There is no saved value in these coordinates.");
70 | }
71 | double[] cc = new double[coord.length - 1];
72 | System.arraycopy(coord, 0, cc, 0, coord.length - 1);
73 | cc[indexSaved] = coord[coord.length - 1];
74 | return cc;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/MemorizeCoordinate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see
Try to use an interpolation method which is not defined or not yet 28 | * implemented.
29 | * 30 | * @author Michaël Michaud 31 | */ 32 | public class NonInvertibleOperationException extends CoordinateOperationException { 33 | 34 | /** 35 | * Create a new NonInvertibleOperationException. 36 | * 37 | * @param exception description of this exception 38 | */ 39 | public NonInvertibleOperationException(String exception) { 40 | super(exception); 41 | } 42 | 43 | /** 44 | * Create a new InterpolationMethodException. 45 | * 46 | * @param op the interpolation method 47 | */ 48 | public NonInvertibleOperationException(CoordinateOperation op) { 49 | super("" + op.getName() + " is not invertible"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/cts/op/OppositeCoordinate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to 3 | * perform Coordinate Transformations using well known geodetic algorithms 4 | * and parameter sets. 5 | * Its main focus are simplicity, flexibility, interoperability, in this order. 6 | * 7 | * This library has been originally developed by Michaël Michaud under the JGeod 8 | * name. It has been renamed CTS in 2009 and shared to the community from 9 | * the OrbisGIS code repository. 10 | * 11 | * CTS is free software: you can redistribute it and/or modify it under the 12 | * terms of the GNU Lesser General Public License as published by the Free Software 13 | * Foundation, either version 3 of the License. 14 | * 15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY 16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License along with 20 | * CTS. If not, seeGeocentricTransformation
33 | * rather than a 2D transformation like NTv2GridShiftTransformation.
34 | *
35 | * @author Michaël Michaud
36 | */
37 | public interface GeocentricTransformation extends CoordinateOperation {
38 |
39 | public GeocentricTransformation inverse() throws NonInvertibleOperationException;
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/transformation/GeocentricTransformationSequence.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see this
. GeocentricTranslations
88 | * are equals if they both are identity, or if all their parameters are
89 | * equal.
90 | *
91 | * @param o The object to compare this ProjectedCRS against
92 | * @return
93 | */
94 | @Override
95 | public boolean equals(Object o) {
96 | if (this == o) {
97 | return true;
98 | }
99 | if (o instanceof GeocentricTransformationSequence) {
100 | if (sequence.length == ((GeocentricTransformationSequence) o).sequence.length) {
101 | for (int i = 0; i < sequence.length; i++) {
102 | if (!sequence[i].equals(((GeocentricTransformationSequence) o).sequence[i])) {
103 | return false;
104 | }
105 | }
106 | }
107 | }
108 | return false;
109 | }
110 |
111 | /**
112 | * Returns the hash code for this GeocentricTranslation.
113 | *
114 | * @return
115 | */
116 | @Override
117 | public int hashCode() {
118 | if (isIdentity()) {
119 | return 0;
120 | }
121 | int hash = 5;
122 | hash = 19 * hash + Arrays.deepHashCode(this.sequence);
123 | return hash;
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/transformation/GridBasedTransformation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see
42 | * If the grid is not packaged into the resources folder then we look into a
43 | * ./cts folder.
44 | * If the grid does not exist in this folder, we try to download it from
45 | * the CTS repository.
46 | *
47 | * @param nameGrid name of the grid with its extension
48 | * @return
49 | * @throws FileNotFoundException
50 | * @throws IOException
51 | */
52 | public static File findGrid(String nameGrid) throws FileNotFoundException, IOException {
53 | //If the grid doesn't exist in resources folder then
54 | //We look into a .cts folder
55 | String ctsFolderPath = new File(System.getProperty("user.home")).getAbsolutePath() + File.separator + ".cts";
56 | File ctsFileFolder = new File(ctsFolderPath);
57 | File gridFile = new File(ctsFolderPath + File.separator + nameGrid);
58 | if (ctsFileFolder.exists()) {
59 | if (gridFile.exists()) {
60 | return gridFile;
61 | } else if (ctsFileFolder.canWrite()) {
62 | //Try to download the grid on the CTS repository
63 | downloadFile(gridFile, new URL(URL_PATH + nameGrid));
64 | return gridFile;
65 | } else {
66 | throw new IOException("Cannot download the grid : " + nameGrid + " into .cts folder");
67 | }
68 | } else {
69 | boolean ctsDir = ctsFileFolder.mkdir();
70 | if (ctsDir && ctsFileFolder.canWrite()) {
71 | //Try to download the grid on the CTS repository
72 | downloadFile(gridFile, new URL(URL_PATH + nameGrid));
73 | return gridFile;
74 | } else {
75 | throw new IOException("Unable to create the .cts folder");
76 | }
77 | }
78 | }
79 |
80 | /**
81 | * Download a file from an URL to a specified target
82 | *
83 | * @param outputFile
84 | * @param urlGrid
85 | * @throws MalformedURLException
86 | * @throws IOException
87 | */
88 | public static void downloadFile(final File outputFile, final URL urlGrid)
89 | throws MalformedURLException, IOException {
90 | BufferedInputStream in = null;
91 | FileOutputStream fout = null;
92 | try {
93 | in = new BufferedInputStream(urlGrid.openStream());
94 | fout = new FileOutputStream(outputFile);
95 |
96 | final byte data[] = new byte[1024];
97 | int count;
98 | while ((count = in.read(data, 0, 1024)) != -1) {
99 | fout.write(data, 0, count);
100 | }
101 | } finally {
102 | try {
103 | if (in != null) {
104 | in.close();
105 | }
106 | } catch (IOException ie) {
107 | //Do nothing
108 | }
109 | try {
110 | if (fout != null) {
111 | fout.close();
112 | }
113 | } catch (IOException ie) {
114 | //Do nothing
115 | }
116 | }
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/src/main/java/org/cts/op/transformation/grids/InterpolationMethodException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see
Try to use an interpolation method which is not defined or not yet 28 | * implemented.
29 | * 30 | * @author Michaël Michaud 31 | */ 32 | public class InterpolationMethodException extends Exception { 33 | 34 | /** 35 | * Create a new InterpolationMethodException. 36 | * 37 | * @param exception description of this exception 38 | */ 39 | public InterpolationMethodException(String exception) { 40 | super(exception); 41 | } 42 | 43 | /** 44 | * Create a new InterpolationMethodException. 45 | * 46 | * @param method the interpolation method 47 | */ 48 | public InterpolationMethodException(Grid.InterpolationMethod method) { 49 | super("" + method + " is not a valid interpolation method"); 50 | } 51 | 52 | /** 53 | * Create a new InterpolationMethodException. 54 | * 55 | * @param method the interpolation method 56 | * @param gridClass the class trying to use the interpolation method 57 | */ 58 | public InterpolationMethodException(Grid.InterpolationMethod method, Class gridClass) { 59 | super("" + method + " is not a valid interpolation method for " + gridClass.getName()); 60 | } 61 | } -------------------------------------------------------------------------------- /src/main/java/org/cts/parser/prj/AbstractPrjElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to 3 | * perform Coordinate Transformations using well known geodetic algorithms 4 | * and parameter sets. 5 | * Its main focus are simplicity, flexibility, interoperability, in this order. 6 | * 7 | * This library has been originally developed by Michaël Michaud under the JGeod 8 | * name. It has been renamed CTS in 2009 and shared to the community from 9 | * the OrbisGIS code repository. 10 | * 11 | * CTS is free software: you can redistribute it and/or modify it under the 12 | * terms of the GNU Lesser General Public License as published by the Free Software 13 | * Foundation, either version 3 of the License. 14 | * 15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY 16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License along with 20 | * CTS. If not, seeQuantity SPEED = Quantity.Factory.create("Speed");Otherwise, you 34 | * can create your own implementation of Quantity : 35 | *
36 | * public class Speed implements Quantity { 37 | * // your implementation 38 | * } 39 | *Note that two quantities are considered as comparable if their 40 | * toString method return equalsIgnoreCase values. 41 | *
42 | * For a complete package about units, quantities and measurements, see JSR-275.
43 | *
44 | * @author Michaël Michaud
45 | */
46 | public interface Quantity {
47 |
48 | public Quantity LENGTH = Factory.create("Length");
49 | public Quantity ANGLE = Factory.create("Angle");
50 | public Quantity NODIM = Factory.create("Dimensionless");
51 | public Quantity TIME = Factory.create("Time");
52 |
53 | /**
54 | * A factory to easily create
55 | * Quantities
from simple Strings.
56 | */
57 | public class Factory {
58 |
59 | /**
60 | * Creates a new Quantity from a String.
61 | *
62 | * @param name the name of the Quantity to be created
63 | * @return a new Quantity object
64 | */
65 | public static Quantity create(final String name) {
66 | return new Quantity() {
67 | @Override
68 | public String toString() {
69 | return name;
70 | }
71 |
72 | @Override
73 | public boolean equals(Object o) {
74 | if (!(o instanceof Quantity)) {
75 | return false;
76 | }
77 | return toString().equalsIgnoreCase(o.toString());
78 | }
79 |
80 | @Override
81 | public int hashCode() {
82 | return 5;
83 | }
84 | };
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/resources/org/cts/log4j.properties:
--------------------------------------------------------------------------------
1 | # Root logger option
2 | log4j.rootLogger=INFO, stdout
3 |
4 | # Direct log messages to stdout
5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
6 | log4j.appender.stdout.Target=System.out
7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
8 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
9 |
10 |
--------------------------------------------------------------------------------
/src/test/java/org/cts/CRSHelperTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Coordinate Transformations Suite (abridged CTS) is a library developped to
3 | * perform Coordinate Transformations using well known geodetic algorithms
4 | * and parameter sets.
5 | * Its main focus are simplicity, flexibility, interoperability, in this order.
6 | *
7 | * This library has been originally developed by Michaël Michaud under the JGeod
8 | * name. It has been renamed CTS in 2009 and shared to the community from
9 | * the OrbisGIS code repository.
10 | *
11 | * CTS is free software: you can redistribute it and/or modify it under the
12 | * terms of the GNU Lesser General Public License as published by the Free Software
13 | * Foundation, either version 3 of the License.
14 | *
15 | * CTS is distributed in the hope that it will be useful, but WITHOUT ANY
16 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 | * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public License along with
20 | * CTS. If not, see