Package org.apache.lucene.geo


package org.apache.lucene.geo
Core geo-spatial types and utilities for handling geographical data and spatial operations in Lucene.

Overview

This package provides classes for representing, indexing, and querying geographical data in Lucene. It uses the WGS84 coordinate system with latitude/longitude pairs to represent points on Earth.

Core Concepts

  • Coordinate System: WGS84 (World Geodetic System 1984)
    • Latitude: -90° to +90° (negative for South, positive for North)
    • Longitude: -180° to +180° (negative for West, positive for East)
  • Distance calculations use haversine formula on a spherical Earth model
  • Areas near poles and the dateline receive special handling

Key Components

  • Point: Represents a point on Earth's surface
  • Rectangle: Defines a bounding box for spatial queries
  • Circle: Represents a circular area with a center point and radius
  • Polygon: Represents an arbitrary polygon shape
  • Line: Represents a path or line string

Common Operations

  • Distance calculations between points
  • Point-in-polygon testing
  • Rectangle containment and intersection
  • Creation of bounding boxes
  • Polygon validation and preprocessing

Usage Examples


 Rectangle bbox = Rectangle.fromPointDistance(51.5, -0.12, 5000); // 5km around London
 Circle circle = new Circle(48.8566, 2.3522, 1000); // 1km around Paris