當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。