• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LineString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中mil.nga.wkb.geom.LineString的典型用法代码示例。如果您正苦于以下问题:Java LineString类的具体用法?Java LineString怎么用?Java LineString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LineString类属于mil.nga.wkb.geom包,在下文中一共展示了LineString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toPolyline

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a {@link LineString} to a {@link PolylineOptions}
 *
 * @param lineString
 * @return
 */
public PolylineOptions toPolyline(LineString lineString) {

    PolylineOptions polylineOptions = new PolylineOptions();
    Double z = null;

    // Try to simplify the number of points in the line string
    List<Point> points = simplifyPoints(lineString.getPoints());

    for (Point point : points) {
        LatLng latLng = toLatLng(point);
        polylineOptions.add(latLng);
        if (point.hasZ()) {
            z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
        }
    }

    if (lineString.hasZ() && z != null) {
        polylineOptions.zIndex(z.floatValue());
    }

    return polylineOptions;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:29,代码来源:GoogleMapShapeConverter.java


示例2: createLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Create a random line string
 *
 * @param hasZ
 * @param hasM
 * @param ring
 * @return
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
                                          boolean ring) {

    LineString lineString = new LineString(hasZ, hasM);

    int numPoints = 2 + ((int) (Math.random() * 9));

    for (int i = 0; i < numPoints; i++) {
        lineString.addPoint(createPoint(hasZ, hasM));
    }

    if (ring) {
        lineString.addPoint(lineString.getPoints().get(0));
    }

    return lineString;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:26,代码来源:TestUtils.java


示例3: comparePolygonAndMapPolygon

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Compare Polygon with Map Polygon
 *
    * @param converter
 * @param polygon
 * @param polygon2
 */
private static void comparePolygonAndMapPolygon(GoogleMapShapeConverter converter,
           Polygon polygon,
		PolygonOptions polygon2) {
	List<LineString> rings = polygon.getRings();
	List<LatLng> points = polygon2.getPoints();
	List<List<LatLng>> holes = polygon2.getHoles();

	TestCase.assertEquals(polygon.numRings(), 1 + holes.size());

	LineString polygonRing = rings.get(0);
	compareLineStringAndLatLngs(converter, polygonRing, points);

	for (int i = 1; i < rings.size(); i++) {
		LineString ring = rings.get(i);
		List<LatLng> hole = holes.get(i - 1);
		compareLineStringAndLatLngs(converter, ring, hole);
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:26,代码来源:GoogleMapShapeConverterUtils.java


示例4: convertMultiLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Test the MultiLineString conversion
 * 
 * @param converter
 * @param multiLineString
 */
private static void convertMultiLineString(
		GoogleMapShapeConverter converter, MultiLineString multiLineString) {

	MultiPolylineOptions polylines = converter.toPolylines(multiLineString);
	TestCase.assertNotNull(polylines);
	TestCase.assertFalse(polylines.getPolylineOptions().isEmpty());

	List<LineString> lineStrings = multiLineString.getLineStrings();
	compareLineStringsAndPolylines(converter, lineStrings,
			polylines.getPolylineOptions());

	MultiLineString multiLineString2 = converter
			.toMultiLineStringFromOptions(polylines);
	compareLineStrings(lineStrings, multiLineString2.getLineStrings());
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:22,代码来源:GoogleMapShapeConverterUtils.java


示例5: convertCompoundCurve

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Test the CompoundCurve conversion
 * 
 * @param converter
 * @param compoundCurve
 */
private static void convertCompoundCurve(GoogleMapShapeConverter converter,
		CompoundCurve compoundCurve) {

	MultiPolylineOptions polylines = converter.toPolylines(compoundCurve);
	TestCase.assertNotNull(polylines);
	TestCase.assertFalse(polylines.getPolylineOptions().isEmpty());

	List<LineString> lineStrings = compoundCurve.getLineStrings();
	compareLineStringsAndPolylines(converter, lineStrings,
			polylines.getPolylineOptions());

	CompoundCurve compoundCurve2 = converter
			.toCompoundCurveWithOptions(polylines);
	compareLineStrings(lineStrings, compoundCurve2.getLineStrings());
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:22,代码来源:GoogleMapShapeConverterUtils.java


示例6: addLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Add the linestring to the path
 *
 * @param simplifyTolerance simplify tolerance in meters
 * @param boundingBox
 * @param transform
 * @param path
 * @param lineString
 */
private void addLineString(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, LineString lineString) {

    List<Point> points = lineString.getPoints();

    if (points.size() >= 2) {

        // Try to simplify the number of points in the LineString
        points = simplifyPoints(simplifyTolerance, points);

        for (int i = 0; i < points.size(); i++) {
            Point point = points.get(i);
            Point webMercatorPoint = getPoint(transform, point);
            float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox,
                    webMercatorPoint.getX());
            float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox,
                    webMercatorPoint.getY());
            if (i == 0) {
                path.moveTo(x, y);
            } else {
                path.lineTo(x, y);
            }
        }
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:34,代码来源:DefaultFeatureTiles.java


示例7: addPolygon

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Add the polygon on the canvas
 *
 * @param simplifyTolerance simplify tolerance in meters
 * @param boundingBox
 * @param transform
 * @param path
 * @param polygon
 */
private void addPolygon(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, Polygon polygon) {
    List<LineString> rings = polygon.getRings();
    if (!rings.isEmpty()) {

        // Add the polygon points
        LineString polygonLineString = rings.get(0);
        List<Point> polygonPoints = polygonLineString.getPoints();
        if (polygonPoints.size() >= 2) {
            addRing(simplifyTolerance, boundingBox, transform, path, polygonPoints);

            // Add the holes
            for (int i = 1; i < rings.size(); i++) {
                LineString holeLineString = rings.get(i);
                List<Point> holePoints = holeLineString.getPoints();
                if (holePoints.size() >= 2) {
                    addRing(simplifyTolerance, boundingBox, transform, path, holePoints);
                }
            }
        }
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:31,代码来源:DefaultFeatureTiles.java


示例8: createLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Create a random line string
 *
 * @param hasZ
 * @param hasM
 * @param ring
 * @return
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
		boolean ring) {

	LineString lineString = new LineString(hasZ, hasM);

	int numPoints = 2 + ((int) (Math.random() * 9));

	for (int i = 0; i < numPoints; i++) {
		lineString.addPoint(createPoint(hasZ, hasM));
	}

	if (ring) {
		lineString.addPoint(lineString.getPoints().get(0));
	}

	return lineString;
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:26,代码来源:TestUtils.java


示例9: getArea

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Get the area of the polygon
 *
 * @param simplifyTolerance
 *            simplify tolerance in meters
 * @param boundingBox
 * @param transform
 * @param lineString
 */
private Area getArea(double simplifyTolerance, BoundingBox boundingBox,
		ProjectionTransform transform, Polygon polygon) {

	Area area = null;

	for (LineString ring : polygon.getRings()) {

		Path2D path = getPath(simplifyTolerance, boundingBox, transform,
				ring);
		Area ringArea = new Area(path);

		if (area == null) {
			area = ringArea;
		} else {
			area.subtract(ringArea);
		}

	}

	return area;
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:31,代码来源:DefaultFeatureTiles.java


示例10: createLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Create a random line string
 * 
 * @param hasZ
 * @param hasM
 * @param ring
 * @return line string
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
		boolean ring) {

	LineString lineString = new LineString(hasZ, hasM);

	int numPoints = 2 + ((int) (Math.random() * 9));

	for (int i = 0; i < numPoints; i++) {
		lineString.addPoint(createPoint(hasZ, hasM));
	}

	if (ring) {
		lineString.addPoint(lineString.getPoints().get(0));
	}

	return lineString;
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:26,代码来源:TestUtils.java


示例11: minimize

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Minimize the line string
 * 
 * @param lineString
 *            line string
 * @param maxX
 *            max positive x value in the geometry projection
 */
private static void minimize(LineString lineString, double maxX) {

	List<Point> points = lineString.getPoints();
	if (points.size() > 1) {
		Point point = points.get(0);
		for (int i = 1; i < points.size(); i++) {
			Point nextPoint = points.get(i);
			if (point.getX() < nextPoint.getX()) {
				if (nextPoint.getX() - point.getX() > point.getX()
						- nextPoint.getX() + (maxX * 2.0)) {
					nextPoint.setX(nextPoint.getX() - (maxX * 2.0));
				}
			} else if (point.getX() > nextPoint.getX()) {
				if (point.getX() - nextPoint.getX() > nextPoint.getX()
						- point.getX() + (maxX * 2.0)) {
					nextPoint.setX(nextPoint.getX() + (maxX * 2.0));
				}
			}
		}
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:30,代码来源:GeometryUtils.java


示例12: add

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Add or subtract a line string to or from the centroid total
 * 
 * @param positive
 *            true if an addition, false if a subtraction
 * @param lineString
 *            line string
 */
private void add(boolean positive, LineString lineString) {
	List<Point> points = lineString.getPoints();
	Point firstPoint = points.get(0);
	if (base == null) {
		base = firstPoint;
	}
	for (int i = 0; i < points.size() - 1; i++) {
		Point point = points.get(i);
		Point nextPoint = points.get(i + 1);
		addTriangle(positive, base, point, nextPoint);
	}
	Point lastPoint = points.get(points.size() - 1);
	if (firstPoint.getX() != lastPoint.getX()
			|| firstPoint.getY() != lastPoint.getY()) {
		addTriangle(positive, base, lastPoint, firstPoint);
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:26,代码来源:CentroidSurface.java


示例13: createPolygon

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
private static Polygon createPolygon() {

		Polygon polygon = new Polygon();
		LineString lineString = new LineString();
		lineString.addPoint(createPoint(-180.0, 45.0, 90.0, 45.0));
		lineString.addPoint(createPoint(-180.0, -90.0, 90.0, 45.0));
		lineString.addPoint(createPoint(90.0, -90.0, 90.0, 45.0));
		lineString.addPoint(createPoint(90.0, 45.0, 90.0, 45.0));
		polygon.addRing(lineString);

		LineString holeLineString = new LineString();
		holeLineString.addPoint(createPoint(-90.0, 0.0, 90.0, 45.0));
		holeLineString.addPoint(createPoint(-90.0, -45.0, 90.0, 45.0));
		holeLineString.addPoint(createPoint(0.0, -45.0, 90.0, 45.0));
		holeLineString.addPoint(createPoint(0.0, 0.0, 90.0, 45.0));
		polygon.addRing(holeLineString);

		return polygon;
	}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:20,代码来源:GeometryUtilsTest.java


示例14: createLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Create a random line string
 * 
 * @param hasZ
 * @param hasM
 * @param ring
 * @return
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
		boolean ring) {

	LineString lineString = new LineString(hasZ, hasM);

	int num = 2 + ((int) (Math.random() * 9));

	for (int i = 0; i < num; i++) {
		lineString.addPoint(createPoint(hasZ, hasM));
	}

	if (ring) {
		lineString.addPoint(lineString.getPoints().get(0));
	}

	return lineString;
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:26,代码来源:WKBTestUtils.java


示例15: toPolyline

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a {@link LineString} to a {@link PolylineOptions}
 *
 * @param lineString
 * @return
 */
public Polyline toPolyline(LineString lineString) {

    Polyline line = new Polyline();
    if (polylineOptions!=null) {
        line.setTitle(polylineOptions.getTitle());
        line.setColor(polylineOptions.getColor());
        line.setGeodesic(polylineOptions.isGeodesic());
        line.setWidth(polylineOptions.getWidth());
        line.setSubDescription(polygonOptions.getSubtitle());
    }

    List<GeoPoint> pts = new ArrayList<>();
    for (Point point : lineString.getPoints()) {
        GeoPoint latLng = toLatLng(point);
        pts.add(latLng);
    }
    line.setPoints(pts);

    return line;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:27,代码来源:OsmMapShapeConverter.java


示例16: populateLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a list of {@link LatLng} to a {@link LineString}
 *
 * @param lineString
 * @param latLngs
 */
public void populateLineString(LineString lineString, List<LatLng> latLngs) {

    for (LatLng latLng : latLngs) {
        Point point = toPoint(latLng, lineString.hasZ(), lineString.hasM());
        lineString.addPoint(point);
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:14,代码来源:GoogleMapShapeConverter.java


示例17: toPolylines

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a {@link MultiLineString} to a {@link MultiPolylineOptions}
 *
 * @param multiLineString
 * @return
 */
public MultiPolylineOptions toPolylines(MultiLineString multiLineString) {

    MultiPolylineOptions polylines = new MultiPolylineOptions();

    for (LineString lineString : multiLineString.getLineStrings()) {
        PolylineOptions polyline = toPolyline(lineString);
        polylines.add(polyline);
    }

    return polylines;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:18,代码来源:GoogleMapShapeConverter.java


示例18: toMultiLineString

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a list of {@link Polyline} to a {@link MultiLineString}
 *
 * @param polylineList
 * @param hasZ
 * @param hasM
 * @return
 */
public MultiLineString toMultiLineString(List<Polyline> polylineList,
                                         boolean hasZ, boolean hasM) {

    MultiLineString multiLineString = new MultiLineString(hasZ, hasM);

    for (Polyline polyline : polylineList) {
        LineString lineString = toLineString(polyline);
        multiLineString.addLineString(lineString);
    }

    return multiLineString;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:21,代码来源:GoogleMapShapeConverter.java


示例19: toMultiLineStringFromList

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a list of List<LatLng> to a {@link MultiLineString}
 *
 * @param polylineList
 * @param hasZ
 * @param hasM
 * @return
 */
public MultiLineString toMultiLineStringFromList(
        List<List<LatLng>> polylineList, boolean hasZ, boolean hasM) {

    MultiLineString multiLineString = new MultiLineString(hasZ, hasM);

    for (List<LatLng> polyline : polylineList) {
        LineString lineString = toLineString(polyline);
        multiLineString.addLineString(lineString);
    }

    return multiLineString;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:21,代码来源:GoogleMapShapeConverter.java


示例20: toCompoundCurveFromList

import mil.nga.wkb.geom.LineString; //导入依赖的package包/类
/**
 * Convert a list of List<LatLng> to a {@link CompoundCurve}
 *
 * @param polylineList
 * @param hasZ
 * @param hasM
 * @return
 */
public CompoundCurve toCompoundCurveFromList(
        List<List<LatLng>> polylineList, boolean hasZ, boolean hasM) {

    CompoundCurve compoundCurve = new CompoundCurve(hasZ, hasM);

    for (List<LatLng> polyline : polylineList) {
        LineString lineString = toLineString(polyline);
        compoundCurve.addLineString(lineString);
    }

    return compoundCurve;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:21,代码来源:GoogleMapShapeConverter.java



注:本文中的mil.nga.wkb.geom.LineString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CPluginCustomization类代码示例发布时间:2022-05-23
下一篇:
Java FieldMatrix类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap