本文整理汇总了Java中com.bbn.openmap.geo.Geo类的典型用法代码示例。如果您正苦于以下问题:Java Geo类的具体用法?Java Geo怎么用?Java Geo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Geo类属于com.bbn.openmap.geo包,在下文中一共展示了Geo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHull
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
public static List<StreamRecord> getHull(List<StreamRecord> points, double toleranceInMeter){
// prepare the geolocation array for computing convex hull
List<Geo> geoPoints = new LinkedList<Geo>();
for (StreamRecord point : points) {
geoPoints.add(new Geo(point.getLocation().getCoordinates().getLatitude(),
point.getLocation().getCoordinates().getLongitude()));
}
double toleranceInRadians = Length.METER.toRadians(toleranceInMeter);
// get the combined convex hull
Geo[] hull = com.bbn.openmap.geo.ConvexHull.hull(
geoPoints.toArray(new Geo[geoPoints.size()]), toleranceInRadians);
// record the updated convex hull by storing the vertexes of the hull
List<StreamRecord> hullRecords = new ArrayList<StreamRecord>();
for (Geo vertex : hull) {
// get the geolocation of each vertex
hullRecords.add(points.get(geoPoints.indexOf(vertex)));
}
return hullRecords;
}
示例2: getPushbackPoly
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Takes a poly that's going to be added to the buffer and removes any
* points that may be too close to the original poly.
*
* @param omp the buffer poly to be added later
* @param dist the distance all points should be from the original
* @return the OMGraphic with good points.
*/
protected OMGraphic getPushbackPoly(OMPoly omp, double dist) {
double[] coords = omp.getLatLonArray();
List<Geo> results = new LinkedList<Geo>();
for (int i = 0; i < coords.length - 2; i += 2) {
Geo g = new Geo(coords[i], coords[i + 1], false);
if (!tooClose(g, dist)) {
results.add(g);
}
}
if (results.size() == 1) {
results.add(new Geo(results.get(0)));
}
if (results.size() > 1) {
return getOMPolyFromGeos(results);
}
return null;
}
示例3: mouseMoved
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
public boolean mouseMoved(MapMouseEvent mme) {
Point2D llp = mme.getLatLon();
Geo geo = Geo.makeGeoDegrees(llp.getY(), llp.getX());
String updateString = "checking mouse event: " + geo;
if (holdingList != null) {
for (OMGraphic omg : holdingList) {
GeoArray ga = (GeoArray) omg.getAttribute(GEOARRAY);
if (ga != null) {
boolean intersects = Intersection.isPointInPolygon(geo, ga);
omg.setFillPaint(intersects ? Color.yellow : Color.blue);
updateString = updateString + " intersects: " + intersects;
}
}
}
fireRequestInfoLine(updateString);
repaint();
return true;
}
示例4: getDist
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Return the distance between that lat/lons defined in radians. The
* returned value is in radians.
*/
public float getDist(Geo g1, Geo g2) {
switch (getLineType()) {
case LINETYPE_STRAIGHT:
float lonDist = ProjMath.lonDistance((float) g2.getLongitude(),
(float) g1.getLongitude());
float latDist = (float) g2.getLatitude() - (float) g1.getLatitude();
return (float) Math.sqrt(lonDist * lonDist + latDist * latDist);
case LINETYPE_RHUMB:
Debug.error("Rhumb distance calculation not implemented.");
case LINETYPE_GREATCIRCLE:
case LINETYPE_UNKNOWN:
default:
return (float) g1.distance(g2);
}
}
示例5: bends
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Method that determines which way the angle between the three points
* bends.
*
* @param g1
* @param g2
* @param g3
* @return STRAIGHT if no bend, BENDS_LEFT if bends less than PI,
* BENDS_RIGHT if bends more than PI.
*/
protected int bends(Geo g1, Geo g2, Geo g3) {
double bend = g1.crossNormalize(g2).distance(g3) - (Math.PI / 2.0);
if (Math.abs(bend) < .0001) {
return STRAIGHT; // essentially straight
} else {
if (bend < 0) {
return BENDS_LEFT;
}
}
return BENDS_RIGHT;
}
示例6: getOMPolyFromGeos
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Converts Vector of Geos to an OMPoly with linetype great_circle. Assumes
* that the List has valid coordinates on it. Does not do a closeness check
* to the original poly, expected that's been done.
*
* @param geos a set of coordinates
* @return OMPoly
*/
protected OMPoly getOMPolyFromGeos(List<Geo> geos) {
double[] tmpCoords = new double[geos.size() * 2];
int index = 0;
for (Geo geo : geos) {
tmpCoords[index++] = geo.getLatitudeRadians();
tmpCoords[index++] = geo.getLongitudeRadians();
}
return new OMPoly(tmpCoords, OMPoly.RADIANS, OMGraphic.LINETYPE_GREATCIRCLE);
}
示例7: getPoly
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Given a RibbonIterator created from two Geos, create a poly from that
* buffer path.
*
* @param rIterator RibbonIterator for one of the legs of corner
* @param side which RibbonIterator side
* @return OMPoly that represents buffered path between geos.
*/
protected OMPoly getPoly(RibbonIterator rIterator, int side) {
List<Geo> bufferCoords = new LinkedList<Geo>();
for (Ribbon rib : rIterator) {
bufferCoords.add(rib.get(side));
}
if (bufferCoords.size() > 1) {
return getOMPolyFromGeos(bufferCoords);
}
return null;
}
示例8: getDist
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Return the distance between that lat/lons defined in radians. The returned
* value is in radians.
*/
public float getDist(Geo g1, Geo g2) {
switch (getLineType()) {
case LINETYPE_STRAIGHT:
float lonDist = ProjMath.lonDistance((float) g2.getLongitude(), (float) g1.getLongitude());
float latDist = (float) g2.getLatitude() - (float) g1.getLatitude();
return (float) Math.sqrt(lonDist * lonDist + latDist * latDist);
case LINETYPE_RHUMB:
Debug.error("Rhumb distance calculation not implemented.");
case LINETYPE_GREATCIRCLE:
case LINETYPE_UNKNOWN:
default:
return (float) g1.distance(g2);
}
}
示例9: projectionChanged
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
public void projectionChanged(ProjectionEvent pEvent) {
if (sourceMapProjection == null)
return;
Projection proj = pEvent.getProjection();
// Save the scale for use in the
overviewScale = proj.getScale();
boolean cylindrical = sourceMapProjection instanceof Cylindrical;
double[] llarr = ProjMath.getProjectionScreenOutlineCoords(sourceMapProjection);
if (llarr != null) {
boolean northPoleVisible = ProjMath.isVisible(sourceMapProjection, new LatLonPoint.Double(90, 0));
boolean southPoleVisible = ProjMath.isVisible(sourceMapProjection, new LatLonPoint.Double(-90, 0));
if (northPoleVisible || southPoleVisible) {
Point2D center = sourceMapProjection.getCenter();
Point2D ul = sourceMapProjection.getUpperLeft();
double dist = Geo.distance(center.getY(), center.getX(), ul.getY(), ul.getX());
poly = new OMCircle(center.getY(), center.getX(), dist, Length.RADIAN);
} else {
poly = new OMPoly(llarr, OMPoly.DECIMAL_DEGREES, cylindrical ? OMGraphic.LINETYPE_STRAIGHT
: OMGraphic.LINETYPE_GREATCIRCLE);
}
areaAttributes.setTo(poly);
// And finally generate the poly
poly.generate(proj);
}
}
示例10: getOuterRing
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Assumes coords represent a polygon, returns an OMAreaList representing
* buffer zone around the outside of a polygon.
*
* @param dist distance of buffer area, in radians. Use Length to convert.
* @return OMAreaList of a polygon that is a distance away from the
* coordinate polygon's edges.
*/
public OMAreaList getOuterRing(double dist) {
OMAreaList ret = new OMAreaList();
if (dist <= bufferLimit) {
return ret;
}
int numCoords = geoCoords.getSize();
if (numCoords >= 3) {
Geo g1 = geoCoords.get(0);
Geo g2 = geoCoords.get(1);
Geo g3 = geoCoords.get(2);
handlePointsForOuterRing(g1, g2, g3, dist, ret);
for (int i = 3; i < numCoords; i++) {
g1 = g2;
g2 = g3;
g3 = geoCoords.get(i);
handlePointsForOuterRing(g1, g2, g3, dist, ret);
}
// test, and close it off if needed
if (!geoCoords.get(0).equals(geoCoords.get(numCoords - 1))) {
g1 = g2;
g2 = g3;
g3 = geoCoords.get(0);
handlePointsForOuterRing(g1, g2, g3, dist, ret);
}
// Now round out the first and last segment, centering on the first
// coordinate
g1 = g2;
g2 = g3;
g3 = geoCoords.get(1);
handlePointsForOuterRing(g1, g2, g3, dist, ret);
}
return ret;
}
示例11: handlePointsForOuterRing
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Takes a corner represented by the three geos, and adds OMGraphics to the
* OMAreaList depending on which way the corner bends - for right turns,
* it'll add an OMLine, OMArc and OMLine. The OMLines will go from half the
* distance of the legs to the rounded corner. The left turn will have a
* polygon added.
*
* @param g1 point 1
* @param g2 point 2
* @param g3 point 3
* @param dist buffer distance in radians
* @param ret OMAreaList to add OMGraphics to.
*/
protected void handlePointsForOuterRing(Geo g1, Geo g2, Geo g3, double dist, OMAreaList ret) {
int bend = bends(g1, g2, g3);
Geo gret = g3;
RibbonIterator leg1 = new RibbonIterator(g1, g2, dist);
OMPoly poly1 = getHalfPoly(leg1, Ribbon.LEFT, false);
RibbonIterator leg2 = new RibbonIterator(g2, g3, dist);
OMPoly poly2 = getHalfPoly(leg2, Ribbon.LEFT, true);
if (bend == STRAIGHT || g2.equals(g3)) {
ret.add(poly1);
ret.add(poly2);
} else {
if (bend == BENDS_LEFT) {
// short, need to find intersection of two legs and remove
// points
// from polys to only go to intersection
double dg12 = g1.distance(g2);
double dg23 = g2.distance(g3);
double legTestDist = dist * 2;
if (dg12 < legTestDist || dg23 < legTestDist) {
addShortLegPolyForIntersection(g1, g2, g3, Ribbon.LEFT, dist, ret);
} else {
addPolyForIntersection(poly1, poly2, dist, ret);
}
} else {
OMGraphic omp = getPushbackPoly(poly1, dist);
if (omp != null) {
ret.add(omp);
}
// Add OMArc in the middle, rounding around a corner
OMGraphic oma = getArc(g2, poly1, poly2);
if (oma != null) {
ret.add(oma);
}
omp = getPushbackPoly(poly2, dist);
if (omp != null) {
ret.add(omp);
}
}
}
}
示例12: getArc
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
/**
* Given two polylines, with the end point of poly1 being the same distance
* from a point as the starting point of poly2, create an arc that connects
* them.
*
* @param gc point
* @param poly1 polyline where the last end point is used
* @param poly2 polyline where the first end point is used.
* @return OMArc
*/
public OMGraphic getArc(Geo gc, OMPoly poly1, OMPoly poly2) {
double[] poly1Coords = poly1.getLatLonArray();
Geo pt1 = new Geo(poly1Coords[poly1Coords.length - 2], poly1Coords[poly1Coords.length - 1], false);
double radAngle1 = gc.azimuth(pt1);
double[] poly2Coords = poly2.getLatLonArray();
Geo pt2 = new Geo(poly2Coords[0], poly2Coords[1], false);
double radAngle2 = gc.azimuth(pt2);
double dist = gc.distance(pt1);
if (radAngle2 < radAngle1) {
radAngle2 += MoreMath.TWO_PI_D;
}
if (logger.isLoggable(Level.FINE)) {
logger.fine(new StringBuilder("Making arg starting at ").append(Length.DECIMAL_DEGREE.fromRadians(radAngle1))
.append(", ")
.append(Length.DECIMAL_DEGREE.fromRadians(radAngle2 - radAngle1))
.toString());
}
List<Geo> points = new LinkedList<Geo>();
double inc = Length.DECIMAL_DEGREE.toRadians(2.0);
double angle = radAngle1 + inc;
while (angle < radAngle2 - inc) {
Geo g = gc.offset(dist, angle);
if (!tooClose(g, dist)) {
points.add(g);
}
angle += inc;
}
return getOMPolyFromGeos(points);
// return new OMArc(gc.getLatitude(), gc.getLongitude(), dist,
// Length.RADIAN, 100, Length.DECIMAL_DEGREE.fromRadians(radAngle1),
// Length.DECIMAL_DEGREE.fromRadians(radAngle2 - radAngle1));
}
示例13: calculateIntersectionsWithDrawnList
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
public void calculateIntersectionsWithDrawnList() {
intersectionResultList.clear();
ExtentIndex rIndex = getRegionIndex(true);
for (OMGraphic omg : drawnList) {
if (omg instanceof OMLine || (omg instanceof OMPoly && !((OMPoly) omg).isPolygon())) {
if (DEBUG) {
Debug.output("GeoIntersectLayer(" + getName()
+ "): Checking line against RegionIndex");
}
GeoPath path = getPathFromOMGraphic(omg);
Iterator intrsctns = null;
Iterator crssngs = null;
if (showCrossingPoints) {
BoundaryCrossing.Collector results = BoundaryCrossing.getCrossings(path, rIndex);
intrsctns = results.iterator();
crssngs = results.getCrossings();
} else {
intrsctns = Intersection.intersect(path, rIndex);
}
while (intrsctns.hasNext()) {
OMPolyRegion ompr = (OMPolyRegion) intrsctns.next();
setRegionAsSelected(ompr);
if (DEBUG) {
Debug.output("GeoIntersectLayer(" + getName() + "): Set Poly for hit");
}
}
int num = 0;
while (crssngs != null && crssngs.hasNext()) {
BoundaryCrossing bc = (BoundaryCrossing) crssngs.next();
Geo geo = bc.getGeo();
OMPoint pgeo = new OMPoint((float) geo.getLatitude(), (float) geo.getLongitude());
pgeo.setFillPaint(Color.WHITE);
pgeo.putAttribute(OMGraphic.LABEL, new OMTextLabeler(Integer.toString(num++)));
intersectionResultList.add(pgeo);
}
} else if (omg instanceof OMPoly) {
for (Iterator hits = Intersection.intersect(new OMPolyRegion((OMPoly) omg), rIndex); hits.hasNext();) {
setRegionAsSelected((OMPolyRegion) hits.next());
if (DEBUG) {
Debug.output("GeoIntersectLayer(" + getName() + "): Set Poly for hit");
}
}
} else if (omg instanceof OMPoint) {
OMPoint omp = (OMPoint) omg;
for (Iterator hits = Intersection.intersect(new GeoPoint.Impl(omp.getLat(), omp.getLon()), rIndex); hits.hasNext();) {
setRegionAsSelected((OMPolyRegion) hits.next());
if (DEBUG) {
Debug.output("GeoIntersectLayer(" + getName() + "): Set Poly for hit");
}
}
}
}
}
示例14: getPointIntersectionImage
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
public OMGraphic getPointIntersectionImage(OMGraphic omg) {
Shape s = omg.getShape();
Projection p = getProjection();
if (s != null && p != null && omg instanceof OMPoly) {
Rectangle r = s.getBounds();
double x = r.getX();
double y = r.getY();
double h = r.getHeight();
double w = r.getWidth();
double[] rawll = ((OMPoly) omg).getLatLonArray();
Point2D llHolder = new Point2D.Double();
Geo g = new Geo(0, 0);
int[] pix = new int[(int) (h * w)];
for (double j = 0; j < h; j++) {
for (double i = 0; i < w; i++) {
boolean inShape = s.contains(i + x, j + y);
p.inverse((int) (i + x), (int) (j + y), llHolder);
g.initialize(llHolder.getY(), llHolder.getX());
boolean inGeo = Intersection.isPointInPolygon(g, rawll, false);
int val = 0;
if (inShape == inGeo) {
val = 0x6200FF00;
} else {
val = 0x62ff0000;
}
pix[(int) (w * j + i)] = val;
}
}
OMRaster omr = new OMRaster((int) x, (int) y, (int) w, (int) h, pix);
omr.setSelectPaint(OMColor.clear);
// omr.setSelected(true);
omr.generate(p);
return omr;
}
return SinkGraphic.getSharedInstance();
}
示例15: OMLineSegment
import com.bbn.openmap.geo.Geo; //导入依赖的package包/类
public OMLineSegment(OMLine oml) {
segArray = oml.getLL();
geos = new Geo[2];
geos[0] = new Geo(segArray[0], segArray[1]);
geos[1] = new Geo(segArray[2], segArray[3]);
}