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


Java LengthIndexedLine类代码示例

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


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

示例1: findCenterPoint

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
private LatLon findCenterPoint()
{
	try
	{
		Geometry geom = JTSConst.toGeometry(this);
		if(!geom.isValid()) return null;

		if(geom instanceof Polygonal)
		{
			return JTSConst.toLatLon(geom.getInteriorPoint());
		}
		else if(geom instanceof Lineal)
		{
			LengthIndexedLine lil = new LengthIndexedLine(geom);
			return JTSConst.toLatLon(lil.extractPoint(geom.getLength() / 2.0));
		}
	}
	catch (Exception e)
	{
		// unable to create proper geometry...
		return null;
	}
	return null;
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:25,代码来源:ElementGeometry.java

示例2: createTripLine

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
public TripLine createTripLine(StreetSegment streetSegment, int triplineIndex, LengthIndexedLine lengthIndexedLine, double lengthIndex, double dist) {
	double l1Bearing = OSMDataStore.getBearing(lengthIndexedLine, lengthIndex);

	synchronized(OSMDataStore.gc) {
		Coordinate p1 = lengthIndexedLine.extractPoint(lengthIndex);
		gc.setStartingGeographicPoint(p1.x, p1.y);
		gc.setDirection(clampAzimuth(l1Bearing + 90), TRIPLINE_RADIUS);
		Point2D tlRight = gc.getDestinationGeographicPoint();
		gc.setDirection(clampAzimuth(l1Bearing - 90), TRIPLINE_RADIUS);
		Point2D tlLeft = gc.getDestinationGeographicPoint();

		Coordinate[] coords = new Coordinate[2];
		coords[0] = new Coordinate(tlLeft.getX(), tlLeft.getY());
		coords[1] = new Coordinate(tlRight.getX(), tlRight.getY());

		TripLine tl = new TripLine(this.triplines.getNextId(), coords, streetSegment.id, triplineIndex, dist);
		return tl;
	}
}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:20,代码来源:OSMDataStore.java

示例3: getBearing

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
private static double getBearing(LengthIndexedLine lil, double index) {
	double epsilon = 0.000009;
	double i0, i1;

	if (index - epsilon <= lil.getStartIndex()) {
		i0 = lil.getStartIndex();
		i1 = i0 + epsilon;
	} else if (index + epsilon >= lil.getEndIndex()) {
		i1 = lil.getEndIndex();
		i0 = i1 - epsilon;
	} else {
		i0 = index - (epsilon / 2);
		i1 = index + (epsilon / 2);
	}

	Coordinate p1 = lil.extractPoint(i0);
	Coordinate p2 = lil.extractPoint(i1);
	synchronized(gc) {
		gc.setStartingGeographicPoint(p1.x, p1.y);
		gc.setDestinationGeographicPoint(p2.x, p2.y);
		return gc.getAzimuth();
	}	
}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:24,代码来源:OSMDataStore.java

示例4: runExtractedLine

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
public void runExtractedLine(String wkt, double start, double end)
        throws ParseException {
    System.out.println("=========================");
    Geometry g1 = rdr.read(wkt);
    System.out.println("Input Geometry: " + g1);
    System.out.println("Indices to extract: " + start + " " + end);

    LengthIndexedLine indexedLine = new LengthIndexedLine(g1);

    Geometry subLine = indexedLine.extractLine(start, end);
    System.out.println("Extracted Line: " + subLine);

    double[] index = indexedLine.indicesOf(subLine);
    System.out.println("Indices of extracted line: " + index[0] + " " + index[1]);

    Coordinate midpt = indexedLine.extractPoint((index[0] + index[1]) / 2);
    System.out.println("Midpoint of extracted line: " + midpt);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:19,代码来源:LinearRefExample.java

示例5: doProfile

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
/**
 * Calculates the profile of a raster map between given {@link Coordinate coordinates}.
 * 
 * <p>Note that novalues and points outside of the given raster region are 
 * added to the list with a {@link HMConstants#doubleNovalue novalue} elevation.
 * 
 * @param mapIter the {@link RandomIter map iterator}.
 * @param gridGeometry the gridgeometry of the map.
 * @param coordinates the {@link Coordinate}s to create the profile on.
 * @return the list of {@link ProfilePoint}s.
 * @throws TransformException
 */
public static List<ProfilePoint> doProfile( RandomIter mapIter, GridGeometry2D gridGeometry, Coordinate... coordinates )
        throws TransformException {
    List<ProfilePoint> profilePointsList = new ArrayList<ProfilePoint>();

    GridEnvelope2D gridRange = gridGeometry.getGridRange2D();
    int rows = gridRange.height;
    int cols = gridRange.width;
    AffineTransform gridToCRS = (AffineTransform) gridGeometry.getGridToCRS();
    double xres = XAffineTransform.getScaleX0(gridToCRS);
    double yres = XAffineTransform.getScaleY0(gridToCRS);

    double step = Math.min(xres, yres);

    LineString line = GeometryUtilities.gf().createLineString(coordinates);
    double lineLength = line.getLength();
    LengthIndexedLine indexedLine = new LengthIndexedLine(line);

    double progressive = 0.0;
    GridCoordinates2D gridCoords;
    while( progressive < lineLength + step ) { // run over by a step to make sure we get the
                                               // last coord back from the extractor
        Coordinate c = indexedLine.extractPoint(progressive);
        gridCoords = gridGeometry.worldToGrid(new DirectPosition2D(c.x, c.y));
        double value = HMConstants.doubleNovalue;
        if (// envelope2d.contains(c.x, c.y) &&
        isInside(cols - 1, rows - 1, gridCoords)) {
            value = mapIter.getSampleDouble(gridCoords.x, gridCoords.y, 0);
        }
        ProfilePoint profilePoint = new ProfilePoint(progressive, value, c.x, c.y);
        profilePointsList.add(profilePoint);
        progressive = progressive + step;
    }
    return profilePointsList;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:47,代码来源:CoverageUtilities.java

示例6: project

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
@Metadata (
    description = "Projects a point onto a line"
  )
public static double project(
    @Metadata ( name="line" )
    Geometry line, 
    @Metadata ( name="point" )
    Geometry pt)
{
	LengthIndexedLine lil = new LengthIndexedLine(line);
	return lil.project(pt.getCoordinate());
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:13,代码来源:LinearRefFunction.java

示例7: projectPt

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
public static Geometry projectPt(Geometry line, Geometry pt)
{
	LengthIndexedLine lil = new LengthIndexedLine(line);
	double len = lil.project(pt.getCoordinate());
	Coordinate projPt = lil.extractPoint(len);
	return geomFact.createPoint(projPt);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:8,代码来源:LinearRefFunction.java

示例8: offsetProjectedPt

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
public static Geometry offsetProjectedPt(Geometry line, Geometry pt, double offsetDistance)
{
	LengthIndexedLine lil = new LengthIndexedLine(line);
	double len = lil.project(pt.getCoordinate());
	Coordinate projPt = lil.extractPoint(len, offsetDistance);
	return geomFact.createPoint(projPt);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:8,代码来源:LinearRefFunction.java

示例9: RiverSectionsFromDtmExtractor

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
/**
 * Extracts sections on the dtm from a riverline at regular intervals.
 * 
 * @param riverLine the river line to consider for the cross sections extraction.
 *          <b>The river line has to be oriented from upstream to downstream.</b>
 * @param elevation the elevation {@link GridCoverage2D}.
 * @param sectionsInterval the distance to use between extracted sections. 
 * @param sectionsWidth the width of the extracted sections.
 * @param bridgePoints the list of bridge {@link Point}s. 
 * @param bridgeWidthAttribute the name of the attribute in the bridges feature that defines the width of the bridge.
 * @param bridgeBuffer a buffer to use for the bridge inside which the bridge is considered to be on the river.
 * @param monitor the progress monitor.
 * @throws Exception
 */
public RiverSectionsFromDtmExtractor( //
        LineString riverLine, //
        GridCoverage2D elevation, //
        double sectionsInterval, //
        double sectionsWidth, //
        List<FeatureMate> bridgePoints, //
        String bridgeWidthAttribute, //
        double bridgeBuffer, //
        IHMProgressMonitor monitor //
) throws Exception {
    crs = elevation.getCoordinateReferenceSystem();

    RandomIter elevIter = CoverageUtilities.getRandomIterator(elevation);
    GridGeometry2D gridGeometry = elevation.getGridGeometry();
    RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(elevation);
    Envelope envelope = regionMap.toEnvelope();

    riverPointsList = new ArrayList<RiverPoint>();
    LengthIndexedLine indexedLine = new LengthIndexedLine(riverLine);

    double length = riverLine.getLength();
    int totalWork = (int) (length / sectionsInterval);
    monitor.beginTask("Extracting sections...", totalWork);
    double runningLength = 0;
    while( runningLength <= length ) {
        // important to extract from left to right

        // TODO extract with point before and after in order to have more regular sections
        Coordinate leftPoint = indexedLine.extractPoint(runningLength, sectionsWidth);
        Coordinate rightPoint = indexedLine.extractPoint(runningLength, -sectionsWidth);
        if (envelope.intersects(leftPoint) && envelope.intersects(rightPoint)) {
            RiverPoint netPoint = getNetworkPoint(riverLine, elevIter, gridGeometry, runningLength, null, leftPoint,
                    rightPoint);
            if (netPoint != null)
                riverPointsList.add(netPoint);
        }
        runningLength = runningLength + sectionsInterval;
        monitor.worked(1);
    }
    monitor.done();

    process(riverLine, sectionsWidth, bridgePoints, bridgeWidthAttribute, bridgeBuffer, elevIter, gridGeometry, envelope,
            indexedLine);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:59,代码来源:RiverSectionsFromDtmExtractor.java

示例10: offsetPt

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
public static Geometry offsetPt(Geometry line, double lenIndex, double offsetDistance)
{
	LengthIndexedLine lil = new LengthIndexedLine(line);
	Coordinate projPt = lil.extractPoint(lenIndex, offsetDistance);
	return geomFact.createPoint(projPt);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:7,代码来源:LinearRefFunction.java

示例11: addOsm

import com.vividsolutions.jts.linearref.LengthIndexedLine; //导入依赖的package包/类
private OSMArea addOsm(Fun.Tuple2<Integer, Integer> tile, Envelope env, OSM osm, Boolean keepCompleteGeometries) {


		String placeName = null;
		Long placePop = null;

		for( Entry<Long, Node> entry : osm.nodes.entrySet() ) {

			Long id = entry.getKey();
			Node node = entry.getValue();
			if (id ==259009337) {
				try {
					long pop = Long.parseLong(node.getTag("population"));
					if (placePop == null || placePop < pop) {
						placePop = pop;
						placeName = node.getTag("name");
					}
				} catch (Exception e) {

				}
			}
		}



		List<StreetSegment> segments = getStreetSegments(osm);


		List<SpatialDataItem> segmentItems = new ArrayList<>();
		List<SpatialDataItem> triplineItems = new ArrayList<>();

		for(StreetSegment segment : segments) {

			if(streetSegments.contains(segment.getSegmentId()))
				continue;

			if(segment.length > MIN_SEGMENT_LEN) {

				LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(segment.getGeometry());

				double scale = (lengthIndexedLine.getEndIndex() - lengthIndexedLine.getStartIndex()) / segment.length;

				List<TripLine> tripLines = new ArrayList<TripLine>();

				tripLines.add(createTripLine(segment, 1, lengthIndexedLine, (OSMDataStore.INTERSECTION_MARGIN_METERS) * scale, OSMDataStore.INTERSECTION_MARGIN_METERS));
				tripLines.add(createTripLine(segment, 2, lengthIndexedLine, ((segment.length - OSMDataStore.INTERSECTION_MARGIN_METERS) * scale), segment.length - OSMDataStore.INTERSECTION_MARGIN_METERS));

				for(TripLine tripLine : tripLines) {
					triplineItems.add(tripLine);
				}
			}
			else {
				jumperDataStore.addJumper(new Jumper(segment));
			}
			
			if(!keepCompleteGeometries)
				segment.truncateGeometry();

			segmentItems.add(segment);

		}

		streetSegments.save(segmentItems);
		jumperDataStore.save();

		triplines.save(triplineItems);

		long zoneOffset =  timeZoneConverter.getOffsetForCoord(env.centre());

		OSMArea osmArea = new OSMArea(osmAreaIds.getNextId(), tile.a, tile.b, Z_INDEX, placeName, placePop, zoneOffset, env);

		osmAreas.put(tile, osmArea);
		db.commit();

		System.out.println("Loaded OSM " + tile.a + ", " + tile.b);
		if(placeName != null)
			System.out.println("\t" + placeName + ", " + placePop);

		return osmArea;
	}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:81,代码来源:OSMDataStore.java


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