Class Location

 1  
 2  
 3 /*
 4  * Copyright (c) 2016 Vivid Solutions.
 5  *
 6  * All rights reserved. This program and the accompanying materials
 7  * are made available under the terms of the Eclipse Public License 2.0
 8  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 9  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
10  * and the Eclipse Distribution License is available at
11  *
12  * http://www.eclipse.org/org/documents/edl-v10.php.
13  */
14 package org.locationtech.jts.geom;
15  
16 /**
17  *  Constants representing the different topological locations
18  *  which can occur in a {@link Geometry}. 
19  *  The constants are also used as the row and column indices 
20  *  of DE-9IM {@link IntersectionMatrix}es. 
21  *
22  *@version 1.7
23  */
24 public class Location {
25   /**
26    * The location value for the interior of a geometry.
27    * Also, DE-9IM row index of the interior of the first geometry and column index of
28    *  the interior of the second geometry. 
29    */
30   public final static int INTERIOR = 0;
31   /**
32    * The location value for the boundary of a geometry.
33    * Also, DE-9IM row index of the boundary of the first geometry and column index of
34    *  the boundary of the second geometry. 
35    */
36   public final static int BOUNDARY = 1;
37   /**
38    * The location value for the exterior of a geometry.
39    * Also, DE-9IM row index of the exterior of the first geometry and column index of
40    *  the exterior of the second geometry. 
41    */
42   public final static int EXTERIOR = 2;
43  
44   /**
45    *  Used for uninitialized location values.
46    */
47   public final static int NONE = -1;
48  
49   /**
50    *  Converts the location value to a location symbol, for example, <code>EXTERIOR => 'e'</code>
51    *  .
52    *
53    *@param  locationValue  either EXTERIOR, BOUNDARY, INTERIOR or NONE
54    *@return                either 'e', 'b', 'i' or '-'
55    */
56   public static char toLocationSymbol(int locationValue) {
57     switch (locationValue) {
58       case EXTERIOR:
59         return 'e';
60       case BOUNDARY:
61         return 'b';
62       case INTERIOR:
63         return 'i';
64       case NONE:
65         return '-';
66     }
67     throw new IllegalArgumentException("Unknown location value: " + locationValue);
68   }
69 }
70  
71  
72