Skip to content

Commit

Permalink
Merge pull request #130 from ridoo/feature/refactor-extras
Browse files Browse the repository at this point in the history
Feature/refactor extras
  • Loading branch information
ridoo committed Nov 2, 2015
2 parents 6d269c8 + a7a4f6d commit 726fbcc
Show file tree
Hide file tree
Showing 105 changed files with 3,952 additions and 822 deletions.
39 changes: 27 additions & 12 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ Licensed under GNU General Public License, Version 2.0
This project includes:
52North Sensor Web Client PDF report structure under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
52°North SOS - 2.0 XML Request Coding under GPLv2
52°North SOS - AQD 1.0 API Operator under GPLv2
52°North SOS - Hibernate Common under GPLv2
52°North SOS - Hibernate Common Datasource under GPLv2
52°North SOS - Hibernate DAOs under GPLv2
52°North SOS - Hibernate Feature Query DAO under GPLv2
52°North SOS - Hibernate Postgres/PostGIS Datasource under GPLv2
52°North SOS - Hibernate Session Factory under GPLv2
52°North SOS - SOS API Module under GPLv2
52°North SOS - WaterML 2.0 XML Coding under GPLv2
52°North Third Party - NCName resolver under BSD 2-clause "Simplified" or "FreeBSD"
License
AntLR Parser Generator under BSD License
Expand Down Expand Up @@ -39,14 +41,18 @@ This project includes:
Batik utility library under The Apache Software License, Version 2.0
Batik XML utility library under The Apache Software License, Version 2.0
c3p0 under GNU Lesser General Public License, Version 2.1 or Eclipse Public License, Version 1.0
ClassLoader leak prevention under Apache 2
Commons IO under The Apache Software License, Version 2.0
Commons Lang under The Apache Software License, Version 2.0
Commons Pool under The Apache Software License, Version 2.0
Core Hibernate O/RM functionality under GNU Lesser General Public License
CORS Filter under The Apache Software License, Version 2.0
dom4j under DOM4J license, http://dom4j.sourceforge.net/dom4j-1.6.1/license.html (BSD style)
EJML under The Apache Software License, Version 2.0
EPSG Authority Service using HSQL database under Lesser General Public License (LGPL) or EPSG database distribution license or BSD License for HSQL
Guava: Google Core Libraries for Java under The Apache Software License, Version 2.0
Hamcrest All under New BSD License
Hamcrest Core under New BSD License
Hibernate Commons Annotations under GNU Lesser General Public License
hibernate-spatial under GNU Lesser General Public License (LGPL) version 2.1
Hibernate/c3p0 Integration under GNU Lesser General Public License
Expand All @@ -73,33 +79,41 @@ This project includes:
Joda-Time under Apache 2
jsr-275 under BSD License
JTS Topology Suite under Lesser General Public License (LGPL)
JUnit under Eclipse Public License 1.0
Log4j Implemented Over SLF4J under Apache Software Licenses
Logback Classic Module under Eclipse Public License - v 1.0 or GNU Lesser General Public License
Logback Core Module under Eclipse Public License - v 1.0 or GNU Lesser General Public License
Main module under Lesser General Public License (LGPL)
mchange-commons-java library under GNU Lesser General Public License, Version 2.1 or Eclipse Public License, Version 1.0
Metadata under Lesser General Public License (LGPL)
OASIS WS-N specification schemas - including WS-BrokeredNotification (v1.3) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OASIS WS-Resources specification schemas v1.2 under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC Filter schema (spec. v2.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC GML schema (spec. v3.2.1) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC O&M schema (spec. v2.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC OWS schema (spec. v1.1.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC Sampling schema (spec. v2.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC SOS schema (spec. v2.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC SWECommon schema (spec. v2.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
OGC SWES schema (spec. v2.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
Mockito under The MIT License
OASIS WS-N specification schemas - including WS-BrokeredNotification (v1.3) under The Apache Software License, Version 2.0
OASIS WS-Resources specification schemas v1.2 under The Apache Software License, Version 2.0
Objenesis under MIT License
OGC Filter schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC GML Coverage schema (spec. v1.0) under The Apache Software License, Version 2.0
OGC GML schema (spec. v3.2.1) under The Apache Software License, Version 2.0
OGC O&M schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC OWS schema (spec. v1.1.0) under The Apache Software License, Version 2.0
OGC Sampling schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC SOS schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC SWECommon schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC SWES schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC WaterML DR schema (spec. v2.0) under The Apache Software License, Version 2.0
OGC WaterML schema (spec. v2.0) under The Apache Software License, Version 2.0
Open GIS Interfaces under OGC copyright or Lesser General Public License (LGPL)
Postgis JDBC Driver under GNU Lesser General Public License
PostgreSQL JDBC Driver under BSD License
Referencing services under Lesser General Public License (LGPL)
Reflections under WTFPL
Sensor Web Timeseries API under GNU General Public License, Version 2.0
Sensor Web Timeseries API - IO under GNU General Public License, Version 2.0
Sensor Web Timeseries API - REST Binding under GNU General Public License, Version 2.0
Sensor Web Timeseries API - SPI under GNU General Public License, Version 2.0
Sensor Web Timeseries API - SPI Impl DAO under GNU General Public License, Version 2.0
Sensor Web Timeseries API - SPI Implementations under GNU General Public License, Version 2.0
Sensor Web Timeseries API - Webapp under GNU General Public License, Version 2.0
servlet-api under CDDL 1.1 or GPL2 w/ CPE
SLF4J API Module under MIT License
Spring AOP under The Apache Software License, Version 2.0
Spring Beans under The Apache Software License, Version 2.0
Expand All @@ -110,8 +124,9 @@ This project includes:
Spring Web under The Apache Software License, Version 2.0
Spring Web MVC under The Apache Software License, Version 2.0
StAX API under The Apache Software License, Version 2.0
W3C WS-Addressing specification schemas (v1.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
W3C xlink schema (spec. v1.1.0) under GNU GENERAL PUBLIC LICENSE Version 2, June 1991
vecmath under GPL 2.0 license w/ CPE
W3C WS-Addressing specification schemas (v1.0) under The Apache Software License, Version 2.0
W3C xlink schema (spec. v1.1.0) under The Apache Software License, Version 2.0
xalan under The Apache Software License, Version 2.0
XML Commons External Components XML APIs under The Apache Software License, Version 2.0
XML Commons External Components XML APIs Extensions under The Apache Software License, Version 2.0
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>check-license</id>
Expand Down Expand Up @@ -465,7 +466,7 @@
<latestYearOfContribution>${currentYear}</latestYearOfContribution>
<latestYearOfContribution>${currentYearDynamic}</latestYearOfContribution>
</properties>
<aggregate>true</aggregate>
<!--<aggregate>true</aggregate>-->
<includes>
<include>src/**/*.java</include>
</includes>
Expand Down
66 changes: 21 additions & 45 deletions timeseries-io/src/main/java/org/n52/io/crs/CRSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
import static java.lang.Boolean.TRUE;
import static org.geotools.factory.Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER;
import static org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactory;
import static org.n52.io.geojson.GeojsonCrs.createNamedCRS;
import static org.n52.io.geojson.GeojsonPoint.createWithCoordinates;
import static org.n52.io.geojson.old.GeojsonCrs.createNamedCRS;
import static org.n52.io.geojson.old.GeojsonPoint.createWithCoordinates;

import org.geotools.factory.Hints;
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.geotools.referencing.CRS.AxisOrder;
import org.n52.io.geojson.GeojsonPoint;
import org.n52.io.geojson.old.GeojsonPoint;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
Expand All @@ -62,6 +62,8 @@ public final class CRSUtils {
* Default is CRS:84 (EPSG:4326 with lon/lat ordering).
*/
public static final String DEFAULT_CRS = "CRS:84";

public static final int EPSG_WGS84 = 4326;

/**
* Internally used spatial reference frame.
Expand Down Expand Up @@ -129,7 +131,7 @@ public GeojsonPoint convertToGeojsonFrom(Point point) {
* if creating the target CRS fails.
*/
public GeojsonPoint convertToGeojsonFrom(Point point, String targetCrs) throws TransformException, FactoryException {
Point transformedPoint = transformInnerToOuter(point, targetCrs);
Point transformedPoint = (Point) transformInnerToOuter(point, targetCrs);
GeojsonPoint asGeoJSON = convertToGeojsonFrom(transformedPoint);
if ( !DEFAULT_CRS.equalsIgnoreCase(targetCrs)) {
asGeoJSON.setCrs(createNamedCRS(targetCrs));
Expand Down Expand Up @@ -225,59 +227,39 @@ public int getSrsIdFromEPSG(String srs) {
}

/**
* Transforms a given point from a given reference to inner reference, which is WGS84 (CRS:84).
* Transforms a given geometry from a given reference to inner reference, which is WGS84 (CRS:84).
*
* @param point
* the point to transform.
* @param geometry
* the geometry to transform.
* @param srcFrame
* the CRS authority code the given point is referenced in.
* @return a point referenced in WGS84
* @return a geometry referenced in WGS84
* @throws FactoryException
* if the creation of {@link CoordinateReferenceSystem} fails or no appropriate
* {@link MathTransform} could be created.
* @throws TransformException
* if transformation fails for any other reason.
*/
public Point transformOuterToInner(Point point, String srcFrame) throws FactoryException, TransformException {
return (Point) transform(point, getCrsFor(srcFrame), internCrs);
public Geometry transformOuterToInner(Geometry geometry, String srcFrame) throws FactoryException, TransformException {
return transform(geometry, getCrsFor(srcFrame), internCrs);
}

/**
* Transforms a given point from its inner reference (which is WGS84 (CRS:84)) to a given reference.
* Transforms a given geometry from its inner reference (which is WGS84 (CRS:84)) to a given reference.
*
* @param point
* the point to transform.
* @param geometry
* the geometry to transform.
* @param destFrame
* the CRS authority code the given point shall be transformed to.
* @return a transformed point with dest reference.
* @return a transformed geometry with dest reference.
* @throws FactoryException
* if the creation of {@link CoordinateReferenceSystem} fails or no appropriate
* {@link MathTransform} could be created.
* @throws TransformException
* if transformation fails for any other reason.
*/
public Point transformInnerToOuter(Point point, String destFrame) throws FactoryException, TransformException {
return (Point) transform(point, internCrs, getCrsFor(destFrame));
}

/**
* Transforms a given point from a given reference to a destinated reference.
*
* @param point
* the point to transform.
* @param srcFrame
* the reference the given point is in.
* @param destFrame
* the reference frame the point shall be transformed to.
* @return a transformed point.
* @throws FactoryException
* if the creation of {@link CoordinateReferenceSystem} fails or no appropriate
* {@link MathTransform} could be created.
* @throws TransformException
* if transformation fails for any other reason.
*/
public Point transform(Point point, String srcFrame, String destFrame) throws FactoryException, TransformException {
return (Point) transform(point, getCrsFor(srcFrame), getCrsFor(destFrame));
public Geometry transformInnerToOuter(Geometry geometry, String destFrame) throws FactoryException, TransformException {
return transform(geometry, internCrs, getCrsFor(destFrame));
}

/**
Expand All @@ -301,9 +283,9 @@ public Geometry transform(Geometry geometry, String srcFrame, String destFrame)
return transform(geometry, getCrsFor(srcFrame), getCrsFor(destFrame));
}

private Geometry transform(Geometry point, CoordinateReferenceSystem srs, CoordinateReferenceSystem dest) throws FactoryException,
private Geometry transform(Geometry geometry, CoordinateReferenceSystem srs, CoordinateReferenceSystem dest) throws FactoryException,
TransformException {
return JTS.transform(point, CRS.findMathTransform(srs, dest));
return JTS.transform(geometry, CRS.findMathTransform(srs, dest));
}

/**
Expand Down Expand Up @@ -353,11 +335,6 @@ private boolean isAxesSwitched(CoordinateReferenceSystem first, CoordinateRefere
return false;
}
return axisOrderFirst != axisOrderSecond;

// AxisDirection sourceFirstAxis = first.getCoordinateSystem().getAxis(0).getDirection();
// AxisDirection targetFirstAxis = second.getCoordinateSystem().getAxis(0).getDirection();
// return sourceFirstAxis.equals(AxisDirection.NORTH) && !targetFirstAxis.equals(AxisDirection.NORTH)
// || !sourceFirstAxis.equals(AxisDirection.NORTH) && targetFirstAxis.equals(AxisDirection.NORTH);
}

/**
Expand Down Expand Up @@ -401,8 +378,7 @@ public static CRSUtils createEpsgForcedXYAxisOrder() {
* @param hints
* Some Geotools {@link Hints} which set behavior and special considerations regarding to the
* spatial operations.
* @throws FactoryException
* if decoding default CRS fails.
* @return an instance of {@link CRSUtils} using given hints
*/
public static CRSUtils createEpsgReferenceHelper(Hints hints) throws IllegalStateException {
return new CRSUtils(getCRSAuthorityFactory("EPSG", hints));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
package org.n52.io.crs;

import static org.n52.io.crs.CRSUtils.DEFAULT_CRS;
import static org.n52.io.geojson.GeojsonCrs.createNamedCRS;
import static org.n52.io.geojson.old.GeojsonCrs.createNamedCRS;

import java.io.Serializable;

import org.n52.io.geojson.GeojsonCrs;
import org.n52.io.geojson.GeojsonPoint;
import org.n52.io.geojson.old.GeojsonCrs;
import org.n52.io.geojson.old.GeojsonPoint;

class EastingNorthing implements Serializable {

Expand Down
Loading

0 comments on commit 726fbcc

Please sign in to comment.