当前位置: 首页>>代码示例>>Java>>正文


Java LineString类代码示例

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


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

示例1: flatten

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
/** */
public static Geometry flatten (GeometryCollection gc) {
    final List<Point> points = new LinkedList<Point>();
    final List<LineString> lines = new LinkedList<LineString>();
    final List<Polygon> polygons = new LinkedList<Polygon>();
    gc.apply(new GeometryFilter() {
            public void filter (Geometry geom) {
                if (geom instanceof Point) {
                    points.add((Point)geom);
                } else if (geom instanceof LineString) {
                    lines.add((LineString)geom);
                } else if (geom instanceof Polygon) {
                    polygons.add((Polygon)geom);
                }
            }
        });
    if (!polygons.isEmpty()) {
        return gc.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
    } else if (!lines.isEmpty()) {
        return gc.getFactory().createMultiLineString(GeometryFactory.toLineStringArray(lines));
    } else {
        return gc.getFactory().createMultiPoint(GeometryFactory.toPointArray(points));
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:25,代码来源:JTSUtil.java

示例2: testParseLineString

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public void testParseLineString() throws IOException {
    XContentBuilder lineGeoJson = XContentFactory.jsonBuilder()
            .startObject()
                .field("type", "LineString")
                .startArray("coordinates")
                .startArray().value(100.0).value(0.0).endArray()
                .startArray().value(101.0).value(1.0).endArray()
                .endArray()
            .endObject();

    List<Coordinate> lineCoordinates = new ArrayList<>();
    lineCoordinates.add(new Coordinate(100, 0));
    lineCoordinates.add(new Coordinate(101, 1));

    LineString expected = GEOMETRY_FACTORY.createLineString(
            lineCoordinates.toArray(new Coordinate[lineCoordinates.size()]));
    assertGeometryEquals(jtsGeom(expected), lineGeoJson);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:GeoJSONShapeParserTests.java

示例3: split

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public static List<LineString> split(LineString given, int maxPoint) {
    List<LineString> result = newArrayList();
    Coordinate[] coordinates = given.getCoordinates();
    int current = 0;
    while (current < coordinates.length) {
        int end = current + maxPoint - 1;
        if (coordinates.length - end < 2) {
            result.add(gf.createLineString(Arrays.copyOfRange(coordinates, current, coordinates.length)));
            return result;
        }
        else {
            result.add(gf.createLineString(Arrays.copyOfRange(coordinates, current, end + 1)));
            current = end;
        }
    }
    throw new IllegalStateException("Unexpected");
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:18,代码来源:LongLineSplitter.java

示例4: should_split_long_line

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Test
public void should_split_long_line() {
    Polygon polygon = polygon(
            new Coordinate(0.0, 0.0),
            new Coordinate(1.0, 0.0),
            new Coordinate(1.0, 1.0),
            new Coordinate(0.0, 1.0),
            new Coordinate(0.0, 0.0));

    List<LineString> lines = LongLineSplitter.split(polygon.getExteriorRing(), 3);

    assertThat(lines).containsExactly(
            linestring(
                    new Coordinate(0.0, 0.0),
                    new Coordinate(1.0, 0.0),
                    new Coordinate(1.0, 1.0)),
            linestring(
                    new Coordinate(1.0, 1.0),
                    new Coordinate(0.0, 1.0),
                    new Coordinate(0.0, 0.0)));
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:22,代码来源:LongLineSplitterTest.java

示例5: filter

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Override
public void filter(Geometry geom) {
    if(geom instanceof LineString) {
        LineString ls = ((LineString) geom);
        
        // look for the original line containing this one
        LineString original = getOriginator(ls);
        if(original == null) {
            LOGGER.log(java.util.logging.Level.WARNING, "Could not find the original line from which the output line " + geom + " originated");
            return;
        }
        
        try {
            applyElevations(ls, original, false);
        } catch(ClippingException e) {
            // fine, let's try with the more expensive way then
            applyElevations(ls, original, true);
        }
    }
    
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:22,代码来源:ClipProcess.java

示例6: build

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Override
public Shape build() {
    Coordinate[] coordinates = this.coordinates.toArray(new Coordinate[this.coordinates.size()]);
    Geometry geometry;
    if(wrapdateline) {
        ArrayList<LineString> strings = decompose(FACTORY, coordinates, new ArrayList<LineString>());

        if(strings.size() == 1) {
            geometry = strings.get(0);
        } else {
            LineString[] linestrings = strings.toArray(new LineString[strings.size()]);
            geometry = FACTORY.createMultiLineString(linestrings);
        }

    } else {
        geometry = FACTORY.createLineString(coordinates);
    }
    return jtsGeometry(geometry);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:LineStringBuilder.java

示例7: assertEquals

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public static void assertEquals(Geometry s1, Geometry s2) {
    if(s1 instanceof LineString && s2 instanceof LineString) {
        assertEquals((LineString) s1, (LineString) s2);

    } else if (s1 instanceof Polygon && s2 instanceof Polygon) {
        assertEquals((Polygon) s1, (Polygon) s2);

    } else if (s1 instanceof MultiPoint && s2 instanceof MultiPoint) {
        Assert.assertEquals(s1, s2);

    } else if (s1 instanceof MultiPolygon && s2 instanceof MultiPolygon) {
        assertEquals((MultiPolygon) s1, (MultiPolygon) s2);

    } else if (s1 instanceof MultiLineString && s2 instanceof MultiLineString) {
        assertEquals((MultiLineString) s1, (MultiLineString) s2);

    } else {
        throw new RuntimeException("equality of shape types not supported [" + s1.getClass().getName() + " and " + s2.getClass().getName() + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ElasticsearchGeoAssertions.java

示例8: newSegment

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Override
public IWaySegment newSegment(long id, LineString geometry, float length,
		String name, String streetType, long wayId, long startNodeId,
		int startNodeIndex, long endNodeId, int endNodeIndex,
		List<IWaySegmentConnection> connections) {
	IWaySegment segment = new WaySegment();
	segment.setId(id);
	segment.setGeometry(geometry);
	segment.setLength(length);
	segment.setName(name);
	segment.setStreetType(streetType);
	segment.setWayId(wayId);
	segment.setStartNodeId(startNodeId);
	segment.setStartNodeIndex(startNodeIndex);
	segment.setEndNodeId(endNodeId);
	segment.setEndNodeIndex(endNodeIndex);
	segment.setCons(connections);
	segment.setEndNodeIndex(endNodeIndex);
	return segment;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:21,代码来源:WayGraphModelFactory.java

示例9: BaseWaySegment

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public BaseWaySegment(long id, LineString geometry, float length, String name, String streetType, long wayId,
		long startNodeId, int startNodeIndex, long endNodeId, int endNodeIndex,
		List<IWaySegmentConnection> cons,
		Map<String, String> tags, Map<String, List<ISegmentXInfo>> xInfo) {
	super(id, xInfo,cons);
	this.geometry = geometry;
	this.length = length;
	this.name = name;
	this.streetType = streetType;
	this.wayId = wayId;
	this.startNodeId = startNodeId;
	this.startNodeIndex = startNodeIndex;
	this.endNodeId = endNodeId;
	this.endNodeIndex = endNodeIndex;
	this.tags = tags;
	this.xInfo = xInfo;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:18,代码来源:BaseWaySegment.java

示例10: WaySegment

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public WaySegment(long id, LineString geometry, float length, String name,
		short maxSpeedTow, short maxSpeedBkw, Short speedCalcTow,
		Short speedCalcBkw, short lanesTow, short lanesBkw, FuncRoadClass frc, FormOfWay formOfWay,
		String streetType, long wayId, long startNodeId,
		int startNodeIndex, long endNodeId, int endNodeIndex,
		Set<Access> accessTow, Set<Access> accessBkw, Boolean tunnel, Boolean bridge, Boolean urban,
		Date timestamp, List<IWaySegmentConnection> cons, Map<String, String> tags,
		Map<String, List<ISegmentXInfo>> xInfo) {
	super(id, geometry, length, name, streetType, wayId, startNodeId, startNodeIndex, 
			endNodeId, endNodeIndex, cons, tags, xInfo);
	this.maxSpeedTow = maxSpeedTow;
	this.maxSpeedBkw = maxSpeedBkw;
	this.speedCalcTow = speedCalcTow;
	this.speedCalcBkw = speedCalcBkw;
	this.lanesTow = lanesTow;
	this.lanesBkw = lanesBkw;
	this.frc = frc;
	this.formOfWay = formOfWay;
	this.accessTow = accessTow;
	this.accessBkw = accessBkw;
	this.tunnel = tunnel;
	this.bridge = bridge;
	this.urban = urban;
	this.timestamp = timestamp;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:26,代码来源:WaySegment.java

示例11: BaseWaySegmentDTOImpl

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public BaseWaySegmentDTOImpl(long id, LineString geometry, String name,
		String streetType, long wayId, long startNodeIndex,
		long startNodeId, long endNodeIndex, long endNodeId,
		Map<String,String> tags,
		List<IBaseSegmentConnectionDTO> connection, Map<String,List<ISegmentXInfoDTO>> xInfo) {
	super(id,connection,xInfo);
	this.geometry = geometry;
	this.name = name;
	this.streetType = streetType;
	this.wayId = wayId;
	this.startNodeIndex = startNodeIndex;
	this.startNodeId = startNodeId;
	this.endNodeIndex = endNodeIndex;
	this.endNodeId = endNodeId;
	this.tags = tags;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:17,代码来源:BaseWaySegmentDTOImpl.java

示例12: WaySegmentDTOImpl

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
public WaySegmentDTOImpl(long id, LineString geometry, String name,
						 short maxSpeedTow, short maxSpeedBkw, short calcSpeedTow,
						 short calcSpeedBkw, short lanesTow, short lanesBkw, short frc, String formOfWay,
						 String streetType, long wayId, long startNodeIndex,
						 long startNodeId, long endNodeIndex, long endNodeId, Set<Access> accessTow,
						 Set<Access> accessBkw, boolean tunnel, boolean bridge, boolean urban,
						 Map<String,String> tags,
						 List<IBaseSegmentConnectionDTO> connection, Map<String,List<ISegmentXInfoDTO>> xInfo) {
	super(id, geometry, name, streetType, wayId, startNodeIndex, startNodeId, endNodeIndex, endNodeId, tags, connection, xInfo);
	this.maxSpeedTow = maxSpeedTow;
	this.maxSpeedBkw = maxSpeedBkw;
	this.calcSpeedTow = calcSpeedTow;
	this.calcSpeedBkw = calcSpeedBkw;
	this.lanesTow = lanesTow;
	this.lanesBkw = lanesBkw;
	this.frc = frc;
	this.formOfWay = formOfWay;
	this.accessTow = accessTow;
	this.accessBkw = accessBkw;
	this.tunnel = tunnel;
	this.bridge = bridge;
	this.urban = urban;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:24,代码来源:WaySegmentDTOImpl.java

示例13: should_return_same_geom_if_necessary

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Test
public void should_return_same_geom_if_necessary() {
    LineString linestring = linestring(
            new Coordinate(0.0, 0.0),
            new Coordinate(1.0, 0.0),
            new Coordinate(1.0, 1.0));

    List<LineString> lines = LongLineSplitter.split(linestring, 3);

    assertThat(lines).containsExactly(
            linestring(
                    new Coordinate(0.0, 0.0),
                    new Coordinate(1.0, 0.0),
                    new Coordinate(1.0, 1.0)));
    assertThat(lines).isEqualTo(LongLineSplitter.split(linestring, 4));
    assertThat(lines).isEqualTo(LongLineSplitter.split(linestring, 5));
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:18,代码来源:LongLineSplitterTest.java

示例14: should_split_linestring

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Test
public void should_split_linestring() {
    LineString linestring = linestring(
            new Coordinate(0.0, 0.0),
            new Coordinate(1.0, 0.0),
            new Coordinate(1.0, 1.0));

    List<LineString> lines = LongLineSplitter.split(linestring, 2);

    assertThat(lines).containsExactly(
            linestring(
                    new Coordinate(0.0, 0.0),
                    new Coordinate(1.0, 0.0)),
            linestring(
                    new Coordinate(1.0, 0.0),
                    new Coordinate(1.0, 1.0)));
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:18,代码来源:LongLineSplitterTest.java

示例15: build

import com.vividsolutions.jts.geom.LineString; //导入依赖的package包/类
@Override
public Shape build() {
    Coordinate[] coordinates = points.toArray(new Coordinate[points.size()]);
    Geometry geometry;
    if(wrapdateline) {
        ArrayList<LineString> strings = decompose(FACTORY, coordinates, new ArrayList<LineString>());

        if(strings.size() == 1) {
            geometry = strings.get(0);
        } else {
            LineString[] linestrings = strings.toArray(new LineString[strings.size()]);
            geometry = FACTORY.createMultiLineString(linestrings);
        }

    } else {
        geometry = FACTORY.createLineString(coordinates);
    }
    return jtsGeometry(geometry);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:BaseLineStringBuilder.java


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