org.apache.lucene.document

## Class ShapeField

- java.lang.Object
- - org.apache.lucene.document.ShapeField

    public final class ShapeField
    extends Object

A base shape utility class used for both LatLon (spherical) and XY (cartesian) shape fields.

`Polygon`'s and `Line`'s are decomposed into a triangular mesh using the `Tessellator` utility class. Each `ShapeField.Triangle` is encoded by this base class and indexed as a seven dimension multi-value field.

Finding all shapes that intersect a range (e.g., bounding box), or target shape, at search time is efficient.

This class defines the static methods for encoding the three vertices of a tessellated triangles as a seven dimension point. The coordinates are converted from double precision values into 32 bit integers so they are sortable at index time.

### Nested Class Summary

Nested Classes
`static class` `ShapeField.DecodedTriangle` Represents a encoded triangle using `decodeTriangle(byte[], DecodedTriangle)`.
`static class` `ShapeField.QueryRelation` Query Relation Types
`static class` `ShapeField.Triangle` polygons are decomposed into tessellated triangles using `Tessellator` these triangles are encoded and inserted as separate indexed POINT fields

### Field Summary

Fields
`protected static FieldType` `TYPE` tessellated triangles are seven dimensions; the first four are the bounding box index dimensions

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `decodeTriangle(byte[] t, ShapeField.DecodedTriangle triangle)` Decode a triangle encoded by `encodeTriangle(byte[], int, int, boolean, int, int, boolean, int, int, boolean)`.
`static void` `encodeTriangle(byte[] bytes, int aLat, int aLon, boolean abFromShape, int bLat, int bLon, boolean bcFromShape, int cLat, int cLon, boolean caFromShape)` A triangle is encoded using 6 points and an extra point with encoded information in three bits of how to reconstruct it.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### TYPE

    protected static final FieldType TYPE

tessellated triangles are seven dimensions; the first four are the bounding box index dimensions

### Method Detail

#### encodeTriangle

    public static void encodeTriangle(byte[] bytes,
                                      int aLat,
                                      int aLon,
                                      boolean abFromShape,
                                      int bLat,
                                      int bLon,
                                      boolean bcFromShape,
                                      int cLat,
                                      int cLon,
                                      boolean caFromShape)

A triangle is encoded using 6 points and an extra point with encoded information in three bits of how to reconstruct it. Triangles are encoded with CCW orientation and might be rotated to limit the number of possible reconstructions to 2^3. Reconstruction always happens from west to east.

#### decodeTriangle

    public static void decodeTriangle(byte[] t,
                                      ShapeField.DecodedTriangle triangle)

Decode a triangle encoded by `encodeTriangle(byte[], int, int, boolean, int, int, boolean, int, int, boolean)`.