Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.openlr.locationreference;
import org.locationtech.jts.geom.Coordinate;
import org.openlr.map.FormOfWay;
import org.openlr.map.FunctionalRoadClass;
import org.openlr.map.Orientation;
import org.openlr.map.SideOfRoad;
import java.util.List;
import java.util.Optional;
/**
* Responsible for creating instances of the various {@link LocationReference} types.
*/
public class LocationReferenceFactory {
/**
* Create path attributes of a location reference point.
*
* @param distance the distance along the path to the next location reference point
* @param lowestFunctionalRoadClass the lowest functional road class along the path to the next location reference point
* @return the path attributes
*/
public PathAttributes createPathAttributes(double distance, FunctionalRoadClass lowestFunctionalRoadClass) {
return new PathAttributesImpl(distance, lowestFunctionalRoadClass);
}
/**
* Create a location reference point.
*
* @param coordinate the coordinate of the point
* @param bearing the bearing of line at this point
* @param functionalRoadClass the functional road class of the line at this point
* @param formOfWay the form of way of the line at this point
* @param pathAttributes the attributes of the path to the next location reference point
* @return the location reference point
*/
public LocationReferencePoint createLocationReferencePoint(Coordinate coordinate, double bearing, FunctionalRoadClass functionalRoadClass, FormOfWay formOfWay, PathAttributes pathAttributes) {
return new LocationReferencePointImpl(
coordinate,
bearing,
functionalRoadClass,
formOfWay,
Optional.ofNullable(pathAttributes));
}
/**
* Create a location reference point.
*
* @param coordinate the coordinate of the point
* @param bearing the bearing of line at this point
* @param functionalRoadClass the functional road class of the line at this point
* @param formOfWay the form of way of the line at this point
* @param distance the distance along the path to the next location reference point
* @param lowestFunctionalRoadClass the lowest functional road class along the path to the next location reference point
* @return the location reference point
*/
public LocationReferencePoint createLocationReferencePoint(Coordinate coordinate, double bearing, FunctionalRoadClass functionalRoadClass, FormOfWay formOfWay, double distance, FunctionalRoadClass lowestFunctionalRoadClass) {
return createLocationReferencePoint(
coordinate,
bearing,
functionalRoadClass,
formOfWay,
new PathAttributesImpl(distance, lowestFunctionalRoadClass));
}
/**
* Create a location reference point without any path attributes. This is used to create the last location reference point of a location reference.
*
* @param coordinate the coordinate of the point
* @param bearing the bearing of line at this point
* @param functionalRoadClass the functional road class of the line at this point
* @param formOfWay the form of way of the line at this point
* @return the location reference point
*/
public LocationReferencePoint createLocationReferencePoint(Coordinate coordinate, double bearing, FunctionalRoadClass functionalRoadClass, FormOfWay formOfWay) {
return createLocationReferencePoint(
coordinate,
bearing,
functionalRoadClass,
formOfWay,
null);
}
/**
* Create a line location reference. Offsets are relative and expressed as a value in the range {@code 0 >= offset < 1.0}.
*
* @param locationReferencePoints the sequence of location reference points that describe the line location
* @param relativePositiveOffset the relative offset between the first and second location reference points where the line location begins
* @param relativeNegativeOffset the relative offset between the last and second to last location reference points where the line location ends
* @return the line location reference
*/
public LineLocationReference createLineLocationReference(List locationReferencePoints, double relativePositiveOffset, double relativeNegativeOffset) {
return new LineLocationReferenceImpl(
locationReferencePoints,
relativePositiveOffset,
relativeNegativeOffset);
}
/**
* Create a geo-coordinate location reference.
*
* @param coordinate the coordinate of the location
* @return the geo-coordinate location reference
*/
public GeoCoordinateLocationReference createGeoCoordinateLocationReference(Coordinate coordinate) {
return new GeoCoordinateLocationReferenceImpl(coordinate);
}
/**
* Create a point along line location reference. The positive offset is relative and is expressed as a value in the range {@code 0 >= offset < 1.0}.
*
* @param firstLocationReferencePoint the first location reference point
* @param lastLocationReferencePoint the last location reference point
* @param relativePositiveOffset the relative offset between the first and last location reference points where the point is found
* @param orientation the orientation of the point along line
* @param sideOfRoad the side of road of the point along line
* @return the point along line location reference
*/
public PointAlongLineLocationReference createPointAlongLineLocationReference(LocationReferencePoint firstLocationReferencePoint, LocationReferencePoint lastLocationReferencePoint, double relativePositiveOffset, Orientation orientation, SideOfRoad sideOfRoad) {
return new PointAlongLineLocationReferenceImpl(
firstLocationReferencePoint,
lastLocationReferencePoint,
relativePositiveOffset,
orientation,
sideOfRoad);
}
/**
* Create a point of interest with access point location reference. The positive offset is relative and is expressed as a value in the range {@code 0 >= offset < 1.0}.
*
* @param firstLocationReferencePoint the first location reference point
* @param lastLocationReferencePoint the last location reference point
* @param relativePositiveOffset the relative offset between the first and last location reference points where the access point is found
* @param orientation the orientation of the access point
* @param sideOfRoad the side of road of the access point
* @param coordinate the coordinate of the point of interest
* @return the point of interest with access point location reference
*/
public PointOfInterestWithAccessPointLocationReference createPointOfInterestWithAccessPointLocationReference(LocationReferencePoint firstLocationReferencePoint, LocationReferencePoint lastLocationReferencePoint, double relativePositiveOffset, Orientation orientation, SideOfRoad sideOfRoad, Coordinate coordinate) {
return new PointOfInterestWithAccessPointLocationReferenceImpl(
firstLocationReferencePoint,
lastLocationReferencePoint,
relativePositiveOffset,
orientation,
sideOfRoad,
coordinate);
}
/**
* Create a circle location reference.
*
* @param center the center of the circle
* @param radius the radius of the circle in meters
* @return the circle location reference
*/
public CircleLocationReference createCircleLocationReference(Coordinate center, int radius) {
return new CircleLocationReferenceImpl(center, radius);
}
/**
* Create a polygon location reference.
*
* @param coordinates the sequence of coordinates that form the shell of the polygon
* @return the polygon location reference
*/
public PolygonLocationReference createPolygonLocationReference(List coordinates) {
return new PolygonLocationReferenceImpl(coordinates);
}
/**
* Create a rectangle location reference.
*
* @param lowerLeft the lower left point of the rectangle
* @param upperRight the upper right point of the rectangle
* @return the rectangle location reference
*/
public RectangleLocationReference createRectangleLocationReference(Coordinate lowerLeft, Coordinate upperRight) {
return new RectangleLocationReferenceImpl(lowerLeft, upperRight);
}
/**
* Create a grid location reference.
*
* @param lowerLeft the lower left point of the grid
* @param upperRight the upper right point of the grid
* @param numberOfColumns the number of columns in the grid
* @param numberOfRows the number of rows in the grid
* @return the grid location reference
*/
public GridLocationReference createGridLocationReference(Coordinate lowerLeft, Coordinate upperRight, int numberOfColumns, int numberOfRows) {
return new GridLocationReferenceImpl(lowerLeft, upperRight, numberOfColumns, numberOfRows);
}
/**
* Create a closed line location reference.
*
* @param locationReferencePoints the sequence of location reference points that describe the closed line location
* @return the closed line location reference
*/
public ClosedLineLocationReference createClosedLineLocationReference(List locationReferencePoints) {
return new ClosedLineLocationReferenceImpl(locationReferencePoints);
}
}