Geofield

Provides a geo-location field type for storing and managing geographic data including points, lines, polygons, and multi-type geometries.

geofield
68,149 sites
102
drupal.org

インストール

Drupal 11, 10, 9 v8.x-1.66
composer require 'drupal/geofield:8.x-1.66'

概要

Geofieldは、地理データの保存と管理を可能にするDrupalの包括的な地理空間フィールドモジュールです。Open Geospatial Consortium(OGC)で定義されているすべてのジオメトリタイプ(Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon)をサポートしています。

このモジュールは、地理データをWell Known Text(WKT)形式で保存し、効率的な空間クエリのために重心座標、バウンディングボックス値、geohashなどの計算済みメタデータも併せて保存します。データ入力用の複数の入力ウィジェット(WKTテキスト、緯度/経度、度-分-秒、バウンディングボックス)と、表示用の複数の出力フォーマッターを提供します。

Geofieldには、正確な距離計算のためのHaversine公式を使用した、近接ベースのフィルタリング、ソート、フィールド表示機能を備えた堅牢なViews統合が含まれています。デフォルトのWKTストレージやPostGISを使用したPostgreSQLなど、拡張された空間機能のための複数のデータベースバックエンドをサポートしています。

基盤モジュールとして、GeofieldはGeofield MapやLeafletなどのコンパニオンモジュールを通じたマッピングライブラリ、Geocoderモジュールを通じたジオコーディングサービス、Search API Locationを通じた検索機能とシームレスに統合されます。

Features

  • すべてのOGCジオメトリタイプを保存:Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon
  • 複数の入力ウィジェット:WKTテキスト入力、HTML5ジオロケーション付き緯度/経度、度-分-秒(DMS)、バウンディングボックス
  • 複数の出力フォーマッター:様々な形式での生出力(WKT、GeoJSON、KML、GPX、Google Geocode)および10進数、DMS、DM形式での緯度/経度表示
  • 近接フィルター、ソート、フィールド、引数ハンドラーを備えた包括的なViews統合
  • Viewsベースの地理クエリ用の矩形境界フィルターと引数
  • 様々な単位(キロメートル、メートル、マイル、ヤード、フィート、海里)での正確な距離計算のためのHaversine公式実装
  • 複数のストレージバックエンド:デフォルトWKTおよびPostgreSQLデータベース用PostGISジオメトリ
  • 起点を定義するための拡張可能な近接ソースプラグインシステム(手動入力、クライアントブラウザジオロケーション、コンテキストフィルター、既存の近接フィルター)
  • 専用のプロセスプラグインによるDrupal 7からの移行サポート
  • 地理データの一括インポート用Feedsモジュール統合
  • 地理フィールドリビジョンの比較用Diffモジュール統合
  • 重心、バウンディングボックス、geohash値の自動計算
  • 自動位置検出のためのHTML5 Geolocation API統合

Use Cases

Store and Display Business Locations

Add a Geofield to a 'Location' content type to store business addresses as geographic points. Use the Latitude/Longitude widget with HTML5 geolocation for easy data entry, and combine with Geofield Map or Leaflet modules to display locations on an interactive map.

Build a Store Locator

Create a Views page with an exposed Geofield Proximity Filter allowing visitors to enter their location or use browser geolocation. Sort results by distance and display the calculated proximity to each store. Combine with rectangular boundary filter for map-based searches.

Track Delivery Routes

Use Geofield to store LineString geometries representing delivery routes. The module stores the complete route as a WKT linestring while computing the centroid and bounding box for efficient spatial queries.

Define Geographic Boundaries

Store Polygon geometries to define sales territories, service areas, or administrative boundaries. Use the Bounding Box widget for quick rectangular areas or the WKT widget for complex polygon shapes.

Migrate Location Data

Use the geofield_latlon migrate process plugin to combine separate latitude and longitude source fields into Geofield values during Drupal migrations.

Bulk Import Locations

Use the Feeds module integration to import location data from CSV files containing either lat/lon columns or WKT/GeoJSON geometry strings.

Tips

  • Use dot (.) as the decimal separator for coordinates, not comma (,), to ensure accurate proximity calculations
  • The Latitude/Longitude widget only supports Point geometries; use the WKT widget for lines and polygons
  • Enable geometry validation on the WKT widget when accepting user input to prevent invalid data
  • Choose the PostGIS backend for PostgreSQL databases to leverage native spatial functions and indexes
  • Proximity calculations use the Haversine formula which is accurate for most use cases but assumes a spherical Earth
  • Views proximity arguments support unit suffixes: km (kilometers), m (meters), mi (miles), yd (yards), ft (feet), nmi (nautical miles)
  • The geohash column enables efficient spatial indexing and nearby searches without complex calculations
  • For large datasets, add database indexes on the lat, lon, and geohash columns for better query performance

Technical Details

Hooks 1
hook_field_views_data

Implements Views data for Geofield fields, adding proximity and boundary handlers.