Merge "Issue #1390 fix envelope reprojection and add serializeable ojects for referenced envelopes Change-Id: I2e79709d1323ed17879b4f59229361fe935aa0ea" into development
Former-commit-id:2a5171c2f3
[formerly 5117b93ee59b6c291d16e084d7a0be0e492b120f] Former-commit-id:63465edb95
This commit is contained in:
commit
6bc665ca3a
6 changed files with 195 additions and 38 deletions
|
@ -1336,7 +1336,7 @@ public class MapUtil {
|
|||
* @return
|
||||
* @throws TransformException
|
||||
*/
|
||||
public static synchronized Envelope reprojectAndIntersect(
|
||||
public static ReferencedEnvelope reprojectAndIntersect(
|
||||
Envelope sourceEnvelope, Envelope targetEnvelope)
|
||||
throws TransformException {
|
||||
try {
|
||||
|
@ -1393,16 +1393,15 @@ public class MapUtil {
|
|||
MathTransform mt = CRS.findMathTransform(
|
||||
targetEnvelope.getCoordinateReferenceSystem(),
|
||||
sourceEnvelope.getCoordinateReferenceSystem());
|
||||
DirectPosition2D top = new DirectPosition2D(
|
||||
targetEnvelope.getMedian(0), targetEnvelope.getMaximum(1));
|
||||
DirectPosition2D bot = new DirectPosition2D(
|
||||
targetEnvelope.getMedian(0), targetEnvelope.getMinimum(1));
|
||||
DirectPosition2D left = new DirectPosition2D(
|
||||
targetEnvelope.getMinimum(0), targetEnvelope.getMedian(1));
|
||||
DirectPosition2D right = new DirectPosition2D(
|
||||
targetEnvelope.getMaximum(0), targetEnvelope.getMedian(1));
|
||||
for (DirectPosition2D edge : new DirectPosition2D[] { top, bot,
|
||||
left, right }) {
|
||||
double[] xTestPoints = { targetEnvelope.getMinimum(0),
|
||||
targetEnvelope.getMedian(0), targetEnvelope.getMaximum(0) };
|
||||
double[] yTestPoints = { targetEnvelope.getMinimum(1),
|
||||
targetEnvelope.getMedian(1), targetEnvelope.getMaximum(1) };
|
||||
|
||||
for (double xTestPoint : xTestPoints) {
|
||||
for (double yTestPoint : yTestPoints) {
|
||||
DirectPosition2D edge = new DirectPosition2D(xTestPoint,
|
||||
yTestPoint);
|
||||
if (!result.contains(edge)) {
|
||||
try {
|
||||
DirectPosition2D tmp = new DirectPosition2D();
|
||||
|
@ -1415,6 +1414,7 @@ public class MapUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (FactoryException e) {
|
||||
|
|
|
@ -36,9 +36,6 @@ package com.raytheon.uf.common.gridcoverage.subgrid;
|
|||
*/
|
||||
public class SubGrid {
|
||||
|
||||
/** The model name */
|
||||
private String modelName;
|
||||
|
||||
/** the upper left x the subgrid will start with */
|
||||
private int upperLeftX;
|
||||
|
||||
|
@ -127,19 +124,4 @@ public class SubGrid {
|
|||
this.upperRightLon = upperRightLon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modelName
|
||||
*/
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelName
|
||||
* the modelName to set
|
||||
*/
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
com.raytheon.uf.common.serialization.adapters.GridGeometrySerialized
|
||||
com.raytheon.uf.common.serialization.adapters.ReferencedEnvelopeSerialized
|
|
@ -50,6 +50,7 @@ import net.sf.cglib.beans.BeanMap;
|
|||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
|
||||
import com.raytheon.uf.common.serialization.BuiltInTypeSupport.CalendarSerializer;
|
||||
import com.raytheon.uf.common.serialization.BuiltInTypeSupport.DateSerializer;
|
||||
|
@ -64,6 +65,7 @@ import com.raytheon.uf.common.serialization.adapters.GridGeometry2DAdapter;
|
|||
import com.raytheon.uf.common.serialization.adapters.GridGeometryAdapter;
|
||||
import com.raytheon.uf.common.serialization.adapters.JTSEnvelopeAdapter;
|
||||
import com.raytheon.uf.common.serialization.adapters.PointAdapter;
|
||||
import com.raytheon.uf.common.serialization.adapters.ReferencedEnvelopeAdapter;
|
||||
import com.raytheon.uf.common.serialization.adapters.StackTraceElementAdapter;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
@ -139,6 +141,8 @@ public class DynamicSerializationManager {
|
|||
registerAdapter(Envelope.class, new JTSEnvelopeAdapter());
|
||||
registerAdapter(GridGeometry2D.class, new GridGeometry2DAdapter());
|
||||
registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter());
|
||||
registerAdapter(ReferencedEnvelope.class,
|
||||
new ReferencedEnvelopeAdapter());
|
||||
registerAdapter(EnumSet.class, new EnumSetAdapter());
|
||||
registerAdapter(StackTraceElement.class, new StackTraceElementAdapter());
|
||||
registerAdapter(Duration.class,
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.serialization.adapters;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.serialization.IDeserializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Adapter for serialization and JAXBing ReferencedEnvelope objects.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 4, 2012 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ReferencedEnvelopeAdapter extends
|
||||
XmlAdapter<ReferencedEnvelopeSerialized, ReferencedEnvelope> implements
|
||||
ISerializationTypeAdapter<ReferencedEnvelope> {
|
||||
|
||||
@Override
|
||||
public ReferencedEnvelope deserialize(IDeserializationContext deserializer)
|
||||
throws SerializationException {
|
||||
CoordinateReferenceSystem crs;
|
||||
try {
|
||||
crs = CRS.parseWKT(deserializer.readString());
|
||||
|
||||
return new ReferencedEnvelope(deserializer.readDouble(),
|
||||
deserializer.readDouble(), deserializer.readDouble(),
|
||||
deserializer.readDouble(), crs);
|
||||
} catch (FactoryException e) {
|
||||
throw new SerializationException(
|
||||
"Error deserializing ReferencedEnvelope, could not read CRS",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ISerializationContext serializer,
|
||||
ReferencedEnvelope object) throws SerializationException {
|
||||
serializer.writeString(object.getCoordinateReferenceSystem().toWKT());
|
||||
serializer.writeDouble(object.getMinX());
|
||||
serializer.writeDouble(object.getMaxX());
|
||||
serializer.writeDouble(object.getMinY());
|
||||
serializer.writeDouble(object.getMaxY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferencedEnvelope unmarshal(ReferencedEnvelopeSerialized v)
|
||||
throws Exception {
|
||||
return new ReferencedEnvelope(v.minX, v.maxX, v.minY, v.maxY,
|
||||
CRS.parseWKT(v.crs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferencedEnvelopeSerialized marshal(ReferencedEnvelope v)
|
||||
throws Exception {
|
||||
if (v == null) {
|
||||
return null;
|
||||
}
|
||||
ReferencedEnvelopeSerialized r = new ReferencedEnvelopeSerialized();
|
||||
r.crs = v.getCoordinateReferenceSystem().toWKT();
|
||||
r.minX = v.getMinX();
|
||||
r.maxX = v.getMaxX();
|
||||
r.minY = v.getMinY();
|
||||
r.maxY = v.getMaxY();
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.serialization.adapters;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* A serializable form of ReferencedEnvelope
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 4, 2012 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class ReferencedEnvelopeSerialized implements ISerializableObject {
|
||||
|
||||
@XmlAttribute
|
||||
public Double minX;
|
||||
|
||||
@XmlAttribute
|
||||
public Double maxX;
|
||||
|
||||
@XmlAttribute
|
||||
public Double minY;
|
||||
|
||||
@XmlAttribute
|
||||
public Double maxY;
|
||||
|
||||
@XmlElement
|
||||
public String crs;
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue