Merge branch 'ss_builds' (12.10.1-5) into Dialog_Refactor
Conflicts: cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/CurrentAlarmQueue.java Former-commit-id:ee328a8050
[formerlyee328a8050
[formerly adf0432a221aaa9b62eaeae5cc7aaecbe1262de2]] Former-commit-id:c915928580
Former-commit-id:202302cb5c
This commit is contained in:
commit
e08a3af27e
10 changed files with 128 additions and 82 deletions
|
@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ public class CcfpResource extends
|
||||||
synchronized (unprocessedRecords) {
|
synchronized (unprocessedRecords) {
|
||||||
records = unprocessedRecords.get(dataTime);
|
records = unprocessedRecords.get(dataTime);
|
||||||
if (records == null) {
|
if (records == null) {
|
||||||
records = new HashSet<CcfpRecord>();
|
records = new LinkedHashSet<CcfpRecord>();
|
||||||
unprocessedRecords.put(dataTime, records);
|
unprocessedRecords.put(dataTime, records);
|
||||||
brandNew = true;
|
brandNew = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,8 @@ import com.raytheon.viz.ui.dialogs.ModeListener;
|
||||||
* May 23, 2012 14952 rferrel Now use refTime/createtime to display
|
* May 23, 2012 14952 rferrel Now use refTime/createtime to display
|
||||||
* selected product
|
* selected product
|
||||||
* Aug 28, 2012 14795 mgamazaychikov Fixed problem with "Unhadled event loop"
|
* Aug 28, 2012 14795 mgamazaychikov Fixed problem with "Unhadled event loop"
|
||||||
* exception associated with closing
|
* exception associated with closing "Current
|
||||||
* "Current Alarm Queue" GUI
|
* Alarm Queue" GUI
|
||||||
* Sep 6, 2012 13365 rferrel Accumulate and Display fix.
|
* Sep 6, 2012 13365 rferrel Accumulate and Display fix.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
|
@ -125,8 +125,8 @@ import com.vividsolutions.jts.io.WKTReader;
|
||||||
* Jul 16, 2012 15091 Qinglu Lin Compute intersection area, which is used for prevent 2nd timezone
|
* Jul 16, 2012 15091 Qinglu Lin Compute intersection area, which is used for prevent 2nd timezone
|
||||||
* from appearing in 2nd and 3rd bullets when not necessary.
|
* from appearing in 2nd and 3rd bullets when not necessary.
|
||||||
* Aug 13, 2012 14493 Qinglu Lin Handled MND time, event time, and TML time specially for COR to NEW.
|
* Aug 13, 2012 14493 Qinglu Lin Handled MND time, event time, and TML time specially for COR to NEW.
|
||||||
|
* Aug 29, 2011 15351 jsanchez Set the timezone for TML time.
|
||||||
* Sep 10, 2012 15295 snaples Added property setting for runtime log to createScript.
|
* Sep 10, 2012 15295 snaples Added property setting for runtime log to createScript.
|
||||||
*
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author njensen
|
* @author njensen
|
||||||
|
@ -242,7 +242,7 @@ public class TemplateRunner {
|
||||||
AffectedAreas[] cancelareas = null;
|
AffectedAreas[] cancelareas = null;
|
||||||
Map<String, Object> intersectAreas = null;
|
Map<String, Object> intersectAreas = null;
|
||||||
Wx wx = null;
|
Wx wx = null;
|
||||||
long wwaMNDTime = 0l;
|
long wwaMNDTime = 0l;
|
||||||
try {
|
try {
|
||||||
t0 = System.currentTimeMillis();
|
t0 = System.currentTimeMillis();
|
||||||
areas = Area.findAffectedAreas(config, warnPolygon, warningArea,
|
areas = Area.findAffectedAreas(config, warnPolygon, warningArea,
|
||||||
|
@ -375,7 +375,7 @@ public class TemplateRunner {
|
||||||
startTime.getTime(), DateUtil.roundDateTo15(endTime)
|
startTime.getTime(), DateUtil.roundDateTo15(endTime)
|
||||||
.getTime(), warnPolygon);
|
.getTime(), warnPolygon);
|
||||||
if (selectedAction == WarningAction.COR) {
|
if (selectedAction == WarningAction.COR) {
|
||||||
wwaMNDTime = wx.getStartTime().getTime();
|
wwaMNDTime = wx.getStartTime().getTime();
|
||||||
} else {
|
} else {
|
||||||
context.put("now", simulatedTime);
|
context.put("now", simulatedTime);
|
||||||
context.put("start", wx.getStartTime());
|
context.put("start", wx.getStartTime());
|
||||||
|
@ -391,7 +391,7 @@ public class TemplateRunner {
|
||||||
context.put("duration", duration);
|
context.put("duration", duration);
|
||||||
|
|
||||||
context.put("event", eventTime);
|
context.put("event", eventTime);
|
||||||
context.put("TMLtime", eventTime);
|
context.put("TMLtime", eventTime);
|
||||||
context.put("ugcline",
|
context.put("ugcline",
|
||||||
FipsUtil.getUgcLine(areas, wx.getEndTime(), 15));
|
FipsUtil.getUgcLine(areas, wx.getEndTime(), 15));
|
||||||
context.put("areaPoly", GisUtil.convertCoords(warngenLayer
|
context.put("areaPoly", GisUtil.convertCoords(warngenLayer
|
||||||
|
@ -550,66 +550,77 @@ public class TemplateRunner {
|
||||||
context.put("etn", etn);
|
context.put("etn", etn);
|
||||||
context.put("start", oldWarn.getIssueTime().getTime());
|
context.put("start", oldWarn.getIssueTime().getTime());
|
||||||
if (oldWarn.getAct().equals("NEW")) {
|
if (oldWarn.getAct().equals("NEW")) {
|
||||||
context.put("now", new Date(wwaMNDTime));
|
context.put("now", new Date(wwaMNDTime));
|
||||||
} else
|
} else
|
||||||
context.put("now", simulatedTime);
|
context.put("now", simulatedTime);
|
||||||
context.put("event", oldWarn.getIssueTime().getTime());
|
context.put("event", oldWarn.getIssueTime().getTime());
|
||||||
|
|
||||||
String message = oldWarn.getRawmessage();
|
String message = oldWarn.getRawmessage();
|
||||||
if (!stormTrackState.originalTrack) {
|
if (!stormTrackState.originalTrack) {
|
||||||
context.put("TMLtime", oldWarn.getStartTime().getTime());
|
context.put("TMLtime", oldWarn.getStartTime().getTime());
|
||||||
} else {
|
} else {
|
||||||
int hour = 0;
|
int hour = 0;
|
||||||
int minute = 0;
|
int minute = 0;
|
||||||
int tmlIndex = message.indexOf("TIME...MOT...LOC");
|
int tmlIndex = message.indexOf("TIME...MOT...LOC");
|
||||||
int zIndex = -1;
|
int zIndex = -1;
|
||||||
if (tmlIndex > 0) {
|
if (tmlIndex > 0) {
|
||||||
zIndex = message.indexOf("Z", tmlIndex);
|
zIndex = message.indexOf("Z", tmlIndex);
|
||||||
if (zIndex > 0) {
|
if (zIndex > 0) {
|
||||||
int startIndex = tmlIndex+16+1;
|
int startIndex = tmlIndex + 16 + 1;
|
||||||
String tmlTime = null;
|
String tmlTime = null;
|
||||||
tmlTime = message.substring(startIndex,startIndex+4);
|
tmlTime = message.substring(startIndex,
|
||||||
if (tmlTime.length() == 4) {
|
startIndex + 4);
|
||||||
hour = Integer.parseInt(tmlTime.substring(0,2));
|
if (tmlTime.length() == 4) {
|
||||||
minute = Integer.parseInt(tmlTime.substring(2,4));
|
hour = Integer
|
||||||
} else if (tmlTime.length() == 3) {
|
.parseInt(tmlTime.substring(0, 2));
|
||||||
hour = Integer.parseInt(tmlTime.substring(0,1));
|
minute = Integer.parseInt(tmlTime.substring(2,
|
||||||
minute = Integer.parseInt(tmlTime.substring(1,3));
|
4));
|
||||||
} else {
|
} else if (tmlTime.length() == 3) {
|
||||||
throw new VizException("The length of hour and minute for TML time is neither 3 nor 4.");
|
hour = Integer
|
||||||
}
|
.parseInt(tmlTime.substring(0, 1));
|
||||||
Calendar c = Calendar.getInstance();
|
minute = Integer.parseInt(tmlTime.substring(1,
|
||||||
c.set(Calendar.HOUR_OF_DAY,hour);
|
3));
|
||||||
c.set(Calendar.MINUTE, minute);
|
} else {
|
||||||
context.put("TMLtime", c.getTime());
|
throw new VizException(
|
||||||
} else {
|
"The length of hour and minute for TML time is neither 3 nor 4.");
|
||||||
throw new VizException("Z, therefore hour and minute, cannot be found in TIME...MOT...LOC line.");
|
}
|
||||||
}
|
Calendar c = Calendar.getInstance(TimeZone
|
||||||
} else {
|
.getTimeZone("GMT"));
|
||||||
// To prevent errors resulting from undefined context("TMLtime")
|
c.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
context.put("TMLtime", oldWarn.getIssueTime().getTime());
|
c.set(Calendar.MINUTE, minute);
|
||||||
}
|
context.put("TMLtime", c.getTime());
|
||||||
}
|
} else {
|
||||||
|
throw new VizException(
|
||||||
|
"Z, therefore hour and minute, cannot be found in TIME...MOT...LOC line.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// To prevent errors resulting from undefined
|
||||||
|
// context("TMLtime")
|
||||||
|
context.put("TMLtime", oldWarn.getIssueTime().getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// corEventtime for "COR to NEW", not for "COR to CON, CAN, or CANCON"
|
// corEventtime for "COR to NEW", not for
|
||||||
if (oldWarn.getAct().equals("NEW")) {
|
// "COR to CON, CAN, or CANCON"
|
||||||
int untilIndex = message.indexOf("UNTIL");
|
if (oldWarn.getAct().equals("NEW")) {
|
||||||
int atIndex = -1;
|
int untilIndex = message.indexOf("UNTIL");
|
||||||
int elipsisIndex = -1;
|
int atIndex = -1;
|
||||||
if (untilIndex > 0) {
|
int elipsisIndex = -1;
|
||||||
atIndex = message.indexOf("AT", untilIndex);
|
if (untilIndex > 0) {
|
||||||
if (atIndex > 0) {
|
atIndex = message.indexOf("AT", untilIndex);
|
||||||
int hhmmIndex = atIndex+3;
|
if (atIndex > 0) {
|
||||||
elipsisIndex = message.indexOf("...", hhmmIndex);
|
int hhmmIndex = atIndex + 3;
|
||||||
if (elipsisIndex > 0) {
|
elipsisIndex = message.indexOf("...", hhmmIndex);
|
||||||
context.put("corToNewMarker","cortonewmarker");
|
if (elipsisIndex > 0) {
|
||||||
context.put("corEventtime",message.substring(hhmmIndex,elipsisIndex));
|
context.put("corToNewMarker", "cortonewmarker");
|
||||||
}
|
context.put("corEventtime", message.substring(
|
||||||
}
|
hhmmIndex, elipsisIndex));
|
||||||
}
|
}
|
||||||
if (untilIndex < 0 || atIndex < 0 || elipsisIndex < 0)
|
}
|
||||||
throw new VizException("Cannot find * AT line.");
|
}
|
||||||
}
|
if (untilIndex < 0 || atIndex < 0 || elipsisIndex < 0)
|
||||||
|
throw new VizException("Cannot find * AT line.");
|
||||||
|
}
|
||||||
|
|
||||||
Calendar cal = oldWarn.getEndTime();
|
Calendar cal = oldWarn.getEndTime();
|
||||||
cal.add(Calendar.MILLISECOND, 1);
|
cal.add(Calendar.MILLISECOND, 1);
|
||||||
|
|
|
@ -336,7 +336,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
@ -487,7 +487,7 @@ LAT...LON ##
|
||||||
#end
|
#end
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
|
|
@ -302,7 +302,7 @@ REMEMBER...A TORNADO WARNING STILL REMAINS IN EFFECT FOR !** PORTION AND COUNTY
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${now}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
@ -1161,7 +1161,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
|
|
@ -627,7 +627,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
|
|
@ -277,7 +277,7 @@ REMEMBER...A TORNADO WARNING STILL REMAINS IN EFFECT FOR !** PORTION AND COUNTY
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${now}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
@ -859,7 +859,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
|
|
@ -322,7 +322,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
|
|
@ -563,7 +563,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
@ -976,7 +976,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${event}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
@ -1402,7 +1402,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE.
|
||||||
#printcoords(${areaPoly}, ${list})
|
#printcoords(${areaPoly}, ${list})
|
||||||
|
|
||||||
TIME...MOT...LOC ##
|
TIME...MOT...LOC ##
|
||||||
${dateUtil.format(${now}, ${timeFormat.time})}Z ##
|
${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ##
|
||||||
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
${mathUtil.roundAndPad(${movementDirection})}DEG ##
|
||||||
${mathUtil.round(${movementInKnots})}KT ##
|
${mathUtil.round(${movementInKnots})}KT ##
|
||||||
#foreach(${eventCoord} in ${eventLocation})
|
#foreach(${eventCoord} in ${eventLocation})
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
package com.raytheon.uf.common.dataplugin.warning.util;
|
package com.raytheon.uf.common.dataplugin.warning.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import com.vividsolutions.jts.geom.GeometryCollection;
|
import com.vividsolutions.jts.geom.GeometryCollection;
|
||||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||||
|
import com.vividsolutions.jts.geom.LineString;
|
||||||
import com.vividsolutions.jts.geom.Polygon;
|
import com.vividsolutions.jts.geom.Polygon;
|
||||||
import com.vividsolutions.jts.geom.TopologyException;
|
import com.vividsolutions.jts.geom.TopologyException;
|
||||||
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
||||||
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
||||||
import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper;
|
import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper;
|
||||||
|
import com.vividsolutions.jts.operation.polygonize.Polygonizer;
|
||||||
|
|
||||||
public class GeometryUtil {
|
public class GeometryUtil {
|
||||||
|
|
||||||
|
@ -218,8 +222,9 @@ public class GeometryUtil {
|
||||||
try {
|
try {
|
||||||
section = g1.intersection(g2);
|
section = g1.intersection(g2);
|
||||||
} catch (TopologyException e) {
|
} catch (TopologyException e) {
|
||||||
// This exception is due to g2 having interior intersections
|
// This exception is due to g2 having interior
|
||||||
section = g1.intersection(g2.buffer(0));
|
// intersections
|
||||||
|
section = clean(g1).intersection(g2.buffer(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section != null) {
|
if (section != null) {
|
||||||
|
@ -232,6 +237,36 @@ public class GeometryUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a geometry from the noded line strings of g.
|
||||||
|
*
|
||||||
|
* @param g
|
||||||
|
* geometry to be cleaned up
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static Geometry clean(Geometry g) {
|
||||||
|
Coordinate[] coords = g.getCoordinates();
|
||||||
|
|
||||||
|
// create a line string
|
||||||
|
GeometryFactory gf = new GeometryFactory();
|
||||||
|
LineString ls = gf.createLineString(coords);
|
||||||
|
|
||||||
|
// node the line string (insert vertices where lines cross)
|
||||||
|
com.vividsolutions.jts.geom.Point pt = gf.createPoint(ls
|
||||||
|
.getCoordinate());
|
||||||
|
Geometry nodedLines = ls.union(pt);
|
||||||
|
|
||||||
|
// create the polygon(s) from the noded line
|
||||||
|
Polygonizer polygonizer = new Polygonizer();
|
||||||
|
polygonizer.add(nodedLines);
|
||||||
|
Collection<Polygon> polygons = polygonizer.getPolygons();
|
||||||
|
|
||||||
|
g = gf.createMultiPolygon(
|
||||||
|
polygons.toArray(new Polygon[polygons.size()])).buffer(0);
|
||||||
|
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the difference between the 2 geometries
|
* Get the difference between the 2 geometries
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue