001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2007-2013 Open Geospatial Consortium, Inc.
006 * All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007 *
008 * Permission to use, copy, and modify this software and its documentation, with
009 * or without modification, for any purpose and without fee or royalty is hereby
010 * granted, provided that you include the following on ALL copies of the software
011 * and documentation or portions thereof, including modifications, that you make:
012 *
013 * 1. The full text of this NOTICE in a location viewable to users of the
014 * redistributed or derivative work.
015 * 2. Notice of any changes or modifications to the OGC files, including the
016 * date changes were made.
017 *
018 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019 * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020 * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021 * THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023 *
024 * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025 * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026 *
027 * The name and trademarks of copyright holders may NOT be used in advertising or
028 * publicity pertaining to the software without specific, written prior permission.
029 * Title to copyright in this software and any associated documentation will at all
030 * times remain with copyright holders.
031 */
032 package org.opengis.geometry;
033
034 import java.util.List;
035 import org.opengis.referencing.crs.CoordinateReferenceSystem;
036 import org.opengis.geometry.coordinate.PointArray;
037 import org.opengis.geometry.coordinate.Position;
038
039
040 /**
041 * A factory for managing {@linkplain DirectPosition direct position} creation.
042 * <p>
043 * This factory will be created for a known {@linkplain CoordinateReferenceSystem
044 * Coordinate Reference System} and {@linkplain Precision precision} model.
045 * </p>
046 *
047 * @author Jody Garnett
048 * @since GeoAPI 2.1
049 */
050 public interface PositionFactory {
051 /**
052 * Returns the coordinate reference system in use for all
053 * {@linkplain DirectPosition direct positions} to be created
054 * through this interface.
055 */
056 CoordinateReferenceSystem getCoordinateReferenceSystem();
057
058 /**
059 * The Precision used used by {@linkplain DirectPosition direct positions}
060 * created via this factory.
061 * <p>
062 * The Precision is used to inform topological operations of the number of
063 * significant digits maintained by the {@link DirectPosition} instances. This
064 * information both helps operations stop when the correct level of detail is
065 * reached, and ensure the result will be valid when rounded to the required
066 * precision.
067 */
068 Precision getPrecision();
069
070 /**
071 * Creates a direct position at the specified location specified by coordinates.
072 * <p>
073 * Implementations have the option of taking ownership of the provided
074 * coordinate array. You should not attempt to reuse this array after it
075 * has been provided to this factory method.
076 *
077 * @param coordinates Array of ordinates used for this DirectPosition
078 * @throws MismatchedDimensionException if the coordinates array length doesn't match
079 * the {@linkplain #getCoordinateReferenceSystem coordinate reference system}
080 * dimension.
081 */
082 DirectPosition createDirectPosition(double[] coordinates)
083 throws MismatchedDimensionException;
084
085 /**
086 * Constructs a position from an other position by copying the coordinate values of the
087 * position. There will be no further reference to the position instance.
088 *
089 * @param position A position.
090 * @return The position which defines the coordinates for the other position.
091 */
092 Position createPosition(Position position);
093
094 /**
095 * Creates a (possibiliy optimized) list for positions. The list is initially
096 * empty. New direct positions can be stored using the {@link List#add} method.
097 */
098 PointArray createPointArray();
099
100 /**
101 * Creates a list for positions initialised from the specified values.
102 * <p>
103 * Implementations have the option of taking ownership of the provided
104 * coordinate array. You should not attempt to reuse this array after it
105 * has been provided to this factory method.
106 *
107 * @param coordinates The coordinates to assign to the list of positions.
108 * @param start The first valid value in the {@code coordinates} array.
109 * @param length The number of valid values in the {@code coordinates} array.
110 * @return The list of positions.
111 */
112 PointArray createPointArray(double[] coordinates, int start, int length);
113
114 /**
115 * Creates a list for positions initialized from the specified values.
116 * <p>
117 * Implementations have the option of taking ownership of the provided
118 * coordinate array. You should not attempt to reuse this array after it
119 * has been provided to this factory method.
120 *
121 * @param coordinates The coordinates to assign to the list of positions.
122 * @param start The first valid value in the {@code coordinates} array.
123 * @param length The number of valid values in the {@code coordinates} array.
124 * @return The list of positions.
125 */
126 PointArray createPointArray(float[] coordinates, int start, int length);
127 }