GEOMETRY
継承
src/data-types.js~ABSTRACT → GEOMETRY
ジオメトリ情報を格納するカラムです。PostgreSQL(PostGISを使用)、MariaDB、またはMySQLでのみ使用可能です。
入力としてGeoJSONを受け入れ、出力としてGeoJSONを返します。
PostGISでは、PostGIS関数`ST_GeomFromGeoJSON`を使用してGeoJSONを解析します。MySQLでは、関数`ST_GeomFromText`を使用して解析します。
従って、幾何オブジェクトの処理にはGeoJSON仕様に従うだけで済みます。以下の例を参照してください。
参照
- DataTypes.GEOGRAPHY
例
ジオメトリタイプの属性の定義
DataTypes.GEOMETRY
DataTypes.GEOMETRY('POINT')
DataTypes.GEOMETRY('POINT', 4326)
新しいポイントの作成
const point = { type: 'Point', coordinates: [-76.984722, 39.807222]}; // GeoJson format: [lng, lat]
User.create({username: 'username', geometry: point });
新しいラインストリングの作成
const line = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] };
User.create({username: 'username', geometry: line });
新しいポリゴンの作成
const polygon = { type: 'Polygon', coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]};
User.create({username: 'username', geometry: polygon });
カスタムSRIDを持つ新しいポイントの作成
const point = {
type: 'Point',
coordinates: [-76.984722, 39.807222], // GeoJson format: [lng, lat]
crs: { type: 'name', properties: { name: 'EPSG:4326'} }
};
User.create({username: 'username', geometry: point })
コンストラクタの概要
公開コンストラクタ | ||
public |
constructor(type: string, srid: string) |