ตอนก่อนนี้ ผมเขียนโปรแกรมทดสอบไลบรารี GDAL/OGR ด้วยการเปิดไฟล์รูปแล้วอ่าน Metadata, ระบบพิกัด ตลอดจนแปลงฟอร์แม็ตของไฟล์รูป จะเห็นถึงความสามารถของไลบรารี ที่เตรียมฟังก์ชั่นทุกสิ่งทุกอย่างครอบคลุมด้าน Geospatial ไว้พร้อมสรรพ และไม่ต้องแปลกใจที่โปรแกรมดังๆ เช่น Google Earth, ArcGIS, Quantum GIS ต่างก็นำไปใช้ ดูชื่อโปรแกรมที่นำไลบรารีไปใช้ ที่นี่ และการดาวน์โหลดและการติดตั้งอ่านที่ blog ของผมได้ ที่นี่ ครั้งก่อนผมเขียนโปรแกรมสำหรับคำนวณแปลงค่าพิกัดระหว่าง UTM และ Geographic (Latitude/Longitude) ด้วยการดัดแปลงโค๊ดภาษา c++ เป็น lazarus จาก GeographicLib ของคุณ Charles Karney ซึ่งมีข้อจำกัดแค่แปลงพิกัด UTM และ Geographic และต้องอยู่ใน datum เดียวกันเท่านั้น ความจริงในไลบรารี GeographicLib ได้เขียนไว้ครอบคลุมการแปลงค่าพิกัดระหว่าง datum ทั้งหมด แต่ด้วยข้อจำกัดภาษา c++ ของผมจึงได้แค่นั้น เมื่อมาศึกษาไลบรารีของ GDAL/OGR พบว่ามีฟังก์ชั่นด้าน Geospatial ครบครันสมกับชื่อ GDAL(Geospatial Data Abstract Library) ที่ทางผู้พัฒนาตั้งชื่อไว้ ดูฟังก์ชั่นด้านการแปลงพิกัดของ GDAL พบว่าครอบคลุมทุกๆ datum ซึงข้อดีของการใช้ไลบรารี ก็คือเขียนโค๊ดน้อยมาก แต่ข้อเสียคือต้องศึกษาฟังก์ชั่นต่างๆในเชิงลึกพอสมควร คู่มือต้องอ่านจาก website ซึ่งก็พอเข้าใจถึงแม้จะไม่ละเอียดมากนักก็ตาม
ปัญหาการแปลงโค๊ดจาก c/c++ เป็น lazarus
เรื่องปัญหาการแปลงโค๊ดผมเคยเขียนไปบ้างแล้ว แต่ที่เสียเวลามากที่สุดก็คือเรื่องธรรมเนียมการเรียกใช้ฟังก์ชั่น stdcall กับ cdecl ตอนแรกไม่ได้ระวังผมใช้ stdcall ทุกฟังก์ชั่น แต่ปัญหาก็คือตอนเรียกใช้ฟังก์ชั่นใน lazarus พบว่าเกิด error ลองดูโค๊ดของ c
OGRSpatialReferenceH CPL_DLL CPL_STDCALL
OSRNewSpatialReference( const char * /* = NULL */);
OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRCloneGeogCS( OGRSpatialReferenceH );
OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRClone( OGRSpatialReferenceH );
void CPL_DLL CPL_STDCALL OSRDestroySpatialReference( OGRSpatialReferenceH );
int CPL_DLL OSRReference( OGRSpatialReferenceH );
int CPL_DLL OSRDereference( OGRSpatialReferenceH );
void CPL_DLL OSRRelease( OGRSpatialReferenceH );
OGRErr CPL_DLL OSRValidate( OGRSpatialReferenceH );
OGRErr CPL_DLL OSRFixupOrdering( OGRSpatialReferenceH );
OGRErr CPL_DLL OSRFixup( OGRSpatialReferenceH );
OGRErr CPL_DLL OSRStripCTParms( OGRSpatialReferenceH );
จะเห็นคีย์เวิร์ดของภาษาซีคือ CPL_STDCALL ถ้าฟังก์ชั่นมีคีย์เวิร์ดนี้ใน lazarus ต้องมีคีย์ stdcall ข้างท้ายฟังก์ชั่น ถ้าไม่มีคีย์ตัวนี้ต้องเขียน cdecl แทน ดูโค๊ดของ lazarus
function OSRNewSpatialReference(const WKT : PCHAR
) : TOGRSpatialReferenceH;
stdcall; external External_Lib name ‘_OSRNewSpatialReference@4’;
function OSRCloneGeogCS(const Handle : TOGRSpatialReferenceH
) : TOGRSpatialReferenceH;
stdcall; external External_Lib name ‘_OSRCloneGeogCS@4’;
function OSRClone(const Handle : TOGRSpatialReferenceH ) : TOGRSpatialReferenceH ;
stdcall; external External_Lib name ‘_OSRClone@4’;
procedure OSRDestroySpatialReference (const Handle : TOGRSpatialReferenceH); stdcall; external External_Lib name ‘_OSRDestroySpatialReference@4’;
function OSRReference(hSRS : TOGRSpatialReferenceH) : longint; cdecl; external External_Lib name ‘OSRReference’;
function OSRDereference(hSRS : TOGRSpatialReferenceH) : longint; cdecl; external External_Lib name ‘OSRDereference’;
procedure OSRRelease(hSRS : TOGRSpatialReferenceH ); cdecl; external External_Lib name ‘OSRRelease’;
function OSRValidate(hSRS : TOGRSpatialReferenceH ) : TOGRErr; cdecl; external External_Lib name ‘OSRValidate’;
function OSRFixupOrdering(hSRS : TOGRSpatialReferenceH) : TOGRErr; cdecl; external External_Lib name ‘OSRFixupOrdering’;
function OSRFixup(hSRS : TOGRSpatialReferenceH ) : TOGRErr; cdecl; external External_Lib name ‘OSRFixup’;
function OSRStripCTParms(hSRS : TOGRSpatialReferenceH) : TOGRErr; cdecl; external External_Lib name ‘OSRStripCTParms’;
ความจริงแล้ว stdcall ก็คือการเรียกฟังก์ชั่นตามแบบ Win32 นั่นเอง โธ่เอ๊ย ผมอ่านตำราของ pascal นานมาแล้วก็พูดถึงเรียกแบบนี้ มันนานจนลืม การใช้ cdecl เป็นการเรียกใช้ฟังก์ชั่นตามรูปแบบภาษาซี ซึ่งทั้งสองวิธีมีการจัดการ stack ของอาร์กิวเมนต์ของฟังก์ชั่นแตกต่างกัน cdecl ยอมให้จำนวนอาร์กิวเมนต์แปรเปลี่ยนได้เช่นฟังก์ชั่นมี 4 อาร์กิวเมนต์ แต่การเรียกใช้ฟังก์ชั่นอาจจะส่งไปแค่ 3 ตัว แต่ใน pascal จะไม่ยอม สนใจเรื่องนี้อ่านวีกิได้ที่ http://en.wikibooks.org/wiki/X86_Disassembly/Calling_Conventions
ความต่างของไลบรารี GDAL/OGR ระหว่างสองโลก Linux และ Windows
เมื่อเข้าใจเรื่องการเรียกฟังก์ชั่น (Calling convention) ระหว่าง cdecl และ stdcall ผมก็เข้าใจได้ทันทีว่าทำไมไลบรารี GDAL ใน linux ถึงไม่เวิร์คในตอนแรกเมื่อคอมไพล์ด้วย lazarus ใน linux เองผมใช้ subversion ทำการติดตั้งและคอมไพล์ GDAL จะได้ไฟล์ไลบรารีที่เป็น .so อยู่หลายไฟล์ ตัวที่สำคัญที่สุดตอนนี้เป็น libgdal.so.1.14.0 ตัวเลขตามหลังคือรุ่นหรือเวอร์ชั่นนั่นเอง และทีสำคัญที่สุดใน linux คือจะต้องเรียกฟังก์ชั่นทุกตัวด้วยคีย์ cdecl เท่านั้น ส่วนในวินโดส์ต้องดูในคีย์ภาษาซีว่าเป็น stdcall หรือ cdecl ตามที่ผมแสดงโค๊ดตัวอย่างให้ดูข้างต้น ตอนนี้ในโค๊ดผมยังไม่ได้ใช้ directive เพื่อตรวจสอบว่ากำลังอยู่ในวินโดส์หรือลีนุกซ์ โค๊ดจึงต้องแยกกันก่อน
Download sourcecode
Sourcecode ของ GDAL/OGR
มีไฟล์หลักๆอยู่แค่ 4 ไฟล์คือ gdal.pas, gdalcore.pas, ogr.pas และ ogrcore.pas ไฟล์ gdal.pas และ ogr.pas ผม declare ตัวแปรต่างๆที่แปลงมาจากภาษาซี ส่วน gdalcore.pas และ ogrcore.pas เป็นไฟล์ที่รวมฟังก์ชั่นที่เป็น export function จาก GDAL ไฟล์ที่จะแสดงให้ดูโค๊ดด้านล่างจะเป็นเวอร์ชั่นสำหรับวินโดส์ มาลองดูโค๊ดของ gdal.pas
//
//*****************************************************************************
// Build 0135
//
// Project: GDAL Lazarus Bindings
// Purpose: Types and Constants for GDAL
// Author: Frank Warmerdam, warmerdam@pobox.com
// Lazarus Wrapper : Prajuab Riabroy
//*****************************************************************************
// Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//*****************************************************************************
unit gdal;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
const
//External_lib = ‘gdal’;
External_lib = ‘gdal16.dll’;
type
TGInt32 = longint;
TGUInt32 = longword;
TGInt16 = shortInt;
TGUInt16 = word;
TGByte = byte;
TGBool = boolean;
TGFloat32 = single;
TGFloat64 = double;
PGInt32 = ^TGInt32;
PGUInt32 = ^TGUInt32;
PGInt16 = ^TGInt16;
PGUInt16 = ^TGUInt16;
PGByte = ^TGByte;
PGBool = ^TGBool;
PGFloat32 = ^TGFloat32;
PGFloat64 = ^TGFloat64;
PPINTEGER = ^PINTEGER;
TDynArrayDouble = array of double;
TDynArrayInt16 = array of shortint;
TDoubleArray6 = array[0..5] of double;
TDoubleArray2 = array[0..1] of double;
TDoubleArray7 = array[0..6] of double;
//* ——————————————————————– */
//* Significant constants. */
//* ——————————————————————– */
TCPLErr = (CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3,
CE_Fatal = 4);
//*! Pixel data types */
TGDALDataType = (GDT_Unknown = 0, GDT_Byte = 1, GDT_UInt16 = 2, GDT_Int16 = 3,
GDT_UInt32 = 4, GDT_Int32 = 5, GDT_Float32 = 6, GDT_Float64 = 7,
GDT_CInt16 = 8, GDT_CInt32 = 9, GDT_CFloat32 = 10, GDT_CFloat64 = 11,
GDT_TypeCount = 12);
//*! Flag indicating read/write, or read-only access to data. */
TGDALAccess = (GA_ReadOnly = 0, GA_Update = 1);
//*! Read/Write flag for RasterIO() method */
TGDALRWFlag = (GF_Read = 0, GF_Write = 1);
//*! Types of color interpretation for raster bands. */
TGDALColorInterp = (GCI_Undefined = 0, GCI_GrayIndex = 1, GCI_PaletteIndex = 2, GCI_RedBand = 3,
GCI_GreenBand = 4, GCI_BlueBand = 5, GCI_AlphaBand = 6, GCI_HueBand = 7,
GCI_SaturationBand = 8, GCI_LightnessBand = 9, GCI_CyanBand = 10, GCI_MagentaBand = 11,
GCI_YellowBand = 12, GCI_BlackBand = 13, GCI_YCbCr_YBand = 14, GCI_YCbCr_CbBand = 15,
GCI_YCbCr_CrBand = 16, GCI_Max = 16);
//*! Types of color interpretations for a GDALColorTable. */
TGDALPaletteInterp = (GPI_Gray = 0, GPI_RGB = 1, GPI_CMYK = 2, GPI_HLS = 3);
TGDALRATFieldType = (GFT_Integer, GFT_Real, GFT_String);
TGDALRATFieldUsage = (GFU_Generic = 0, GFU_PixelCount = 1, GFU_Name = 2, GFU_Min = 3,
GFU_Max = 4, GFU_MinMax = 5, GFU_Red = 6, GFU_Green = 7,
GFU_Blue = 8, GFU_Alpha = 9, GFU_RedMin = 10, GFU_GreenMin = 11,
GFU_BlueMin = 12, GFU_AlphaMin = 13, GFU_RedMax = 14, GFU_GreenMax = 15,
GFU_BlueMax = 16, GFU_AlphaMax = 17, GFU_MaxCount);
//* ——————————————————————– */
//* Callback "progress" function. */
//* ——————————————————————– */
TGDALProgressFunc = function(dfComplete : double; const pszMessage : PCHAR;
pProgressArg : POINTER) : longint;
TGDALDerivedPixelFunc = function(papoSources : PPOINTER; nSources : longint;
pData : POINTER; nBufXSize, nBufYSize : longint;
eSrcType : TGDALDataType;
eBufType : TGDALDataType;
nPixelSpace, nLineSpace : longint): TCPLErr;
//* ——————————————————————– */
//* Define handle types related to various internal classes. */
//* ——————————————————————– */
TGDALMajorObjectH = POINTER;
TGDALDatasetH = POINTER;
TGDALRasterBandH = POINTER;
TGDALDriverH = POINTER;
TGDALColorTableH = POINTER;
TGDALRasterAttributeTableH = POINTER;
PGDALRasterBandH = ^TGDALRasterBandH;
PGDALDatasetH = ^TGDALDatasetH;
PPGDALDatasetH = ^PGDALDatasetH;
const
//* ==================================================================== */
//* Registration/driver related. */
//* ==================================================================== */
DMD_SHORTNAME : PCHAR = ‘DMD_SHORTNAME’;
DMD_LONGNAME : PCHAR = ‘DMD_LONGNAME’;
DMD_HELPTOPIC : PCHAR = ‘DMD_HELPTOPIC’;
DMD_MIMETYPE : PCHAR = ‘DMD_MIMETYPE’;
DMD_EXTENSION : PCHAR = ‘DMD_EXTENSION’;
DMD_CREATIONOPTIONLIST : PCHAR = ‘DMD_CREATIONOPTIONLIST’;
DMD_CREATIONDATATYPES : PCHAR = ‘DMD_CREATIONDATATYPES’;
DCAP_CREATE : PCHAR = ‘DCAP_CREATE’;
DCAP_CREATECOPY : PCHAR = ‘DCAP_CREATECOPY’;
GDALMD_AREA_OR_POINT = ‘AREA_OR_POINT’;
GDALMD_AOP_AREA = ‘Area’;
GDALMD_AOP_POINT = ‘Point’;
CPLE_WrongFormat = 200;
GDAL_DMD_LONGNAME = ‘DMD_LONGNAME’;
GDAL_DMD_HELPTOPIC = ‘DMD_HELPTOPIC’;
GDAL_DMD_MIMETYPE = ‘DMD_MIMETYPE’;
GDAL_DMD_EXTENSION = ‘DMD_EXTENSION’;
GDAL_DMD_CREATIONOPTIONLIST = ‘DMD_CREATIONOPTIONLIST’;
GDAL_DMD_CREATIONDATATYPES = ‘DMD_CREATIONDATATYPES’;
GDAL_DCAP_CREATE = ‘DCAP_CREATE’;
GDAL_DCAP_CREATECOPY = ‘DCAP_CREATECOPY’;
GDAL_DCAP_VIRTUALIO = ‘DCAP_VIRTUALIO’;
//SRCVAL(papoSource, eSrcType, ii)
//SRCVAL – Macro which may be used by pixel functions to obtain a pixel from a source buffer.
GMF_ALL_VALID = $01;
GMF_PER_DATASET = $02;
GMF_ALPHA = $04;
GMF_NODATA = $08;
type
TGDAL_GCP = record
pszId : PCHAR;//Unique identifier, often numeric.
pszInfo : PCHAR;//Informational message or "".
dfGCPPixel : double;//Pixel (x) location of GCP on raster.
dfGCPLine : double;//Line (y) location of GCP on raster.
dfGCPX : double;//X position of GCP in georeferenced space.
dfGCPY : double;//Y position of GCP in georeferenced space.
dfGCPZ : double;//Elevation of GCP, or zero if not known.
end;
PGDAL_GCP = ^TGDAL_GCP;
TGDALColorEntry = record
c1 : shortint;
c2 : shortint;
c3 : shortint;
c4 : shortint;
end;
PGDALColorEntry = ^TGDALColorEntry;
TGDALRPCInfo = record
dfLINE_OFF : double;
dfSAMP_OFF : double;
dfLAT_OFF : double;
dfLONG_OFF : double;
dfHEIGHT_OFF : double;
dfLINE_SCALE : double;
dfSAMP_SCALE : double;
dfLAT_SCALE : double;
dfLONG_SCALE : double;
dfHEIGHT_SCALE : double;
adfLINE_NUM_COEFF : array[0..20] of double;
adfLINE_DEN_COEFF : array[0..20] of double;
adfSAMP_NUM_COEFF : array[0..20] of double;
adfSAMP_DEN_COEFF : array[0..20] of double;
dfMIN_LONG : double;
dfMIN_LAT : double;
dfMAX_LONG : double;
dfMAX_LAT : double;
end;
PGDALRPCInfo = ^TGDALRPCInfo;
implementation
end.
ต่อไปเป็น gdal.pas ด้านท้ายสุดเป็นคลาส TGDALMajorobject ที่ได้จากการ wrapper
//
//*****************************************************************************
// Build 0135
//
// Project: GDAL Lazarus Bindings
// Purpose: Types and Constants for GDAL
// Author: Frank Warmerdam, warmerdam@pobox.com
// Lazarus Wrapper : Prajuab Riabroy
//*****************************************************************************
// Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//*****************************************************************************
unit gdal;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
const
{$IFDEF MSWINDOWS}
GDALLib = 'gdal16.dll';
{$ENDIF}
{$IFDEF LINUX}
GDALLib = 'libgdal.so';//.1.14.0';
{$ENDIF}
type
TGInt32 = longint;
TGUInt32 = longword;
TGInt16 = shortInt;
TGUInt16 = word;
TGByte = byte;
TGBool = boolean;
TGFloat32 = single;
TGFloat64 = double;
PGInt32 = ^TGInt32;
PGUInt32 = ^TGUInt32;
PGInt16 = ^TGInt16;
PGUInt16 = ^TGUInt16;
PGByte = ^TGByte;
PGBool = ^TGBool;
PGFloat32 = ^TGFloat32;
PGFloat64 = ^TGFloat64;
PPINTEGER = ^PINTEGER;
TDynArrayDouble = array of double;
TDynArrayInt16 = array of shortint;
TDoubleArray6 = array[0..5] of double;
TDoubleArray2 = array[0..1] of double;
TDoubleArray7 = array[0..6] of double;
//* -------------------------------------------------------------------- */
//* Significant constants. */
//* -------------------------------------------------------------------- */
TCPLErr = (CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3,
CE_Fatal = 4);
//*! Pixel data types */
TGDALDataType = (GDT_Unknown = 0, GDT_Byte = 1, GDT_UInt16 = 2, GDT_Int16 = 3,
GDT_UInt32 = 4, GDT_Int32 = 5, GDT_Float32 = 6, GDT_Float64 = 7,
GDT_CInt16 = 8, GDT_CInt32 = 9, GDT_CFloat32 = 10, GDT_CFloat64 = 11,
GDT_TypeCount = 12);
//*! Flag indicating read/write, or read-only access to data. */
TGDALAccess = (GA_ReadOnly = 0, GA_Update = 1);
//*! Read/Write flag for RasterIO() method */
TGDALRWFlag = (GF_Read = 0, GF_Write = 1);
//*! Types of color interpretation for raster bands. */
TGDALColorInterp = (GCI_Undefined = 0, GCI_GrayIndex = 1, GCI_PaletteIndex = 2, GCI_RedBand = 3,
GCI_GreenBand = 4, GCI_BlueBand = 5, GCI_AlphaBand = 6, GCI_HueBand = 7,
GCI_SaturationBand = 8, GCI_LightnessBand = 9, GCI_CyanBand = 10, GCI_MagentaBand = 11,
GCI_YellowBand = 12, GCI_BlackBand = 13, GCI_YCbCr_YBand = 14, GCI_YCbCr_CbBand = 15,
GCI_YCbCr_CrBand = 16, GCI_Max = 16);
//*! Types of color interpretations for a GDALColorTable. */
TGDALPaletteInterp = (GPI_Gray = 0, GPI_RGB = 1, GPI_CMYK = 2, GPI_HLS = 3);
TGDALRATFieldType = (GFT_Integer, GFT_Real, GFT_String);
TGDALRATFieldUsage = (GFU_Generic = 0, GFU_PixelCount = 1, GFU_Name = 2, GFU_Min = 3,
GFU_Max = 4, GFU_MinMax = 5, GFU_Red = 6, GFU_Green = 7,
GFU_Blue = 8, GFU_Alpha = 9, GFU_RedMin = 10, GFU_GreenMin = 11,
GFU_BlueMin = 12, GFU_AlphaMin = 13, GFU_RedMax = 14, GFU_GreenMax = 15,
GFU_BlueMax = 16, GFU_AlphaMax = 17, GFU_MaxCount);
//* -------------------------------------------------------------------- */
//* Callback "progress" function. */
//* -------------------------------------------------------------------- */
TGDALProgressFunc = function(dfComplete : double; const pszMessage : PCHAR;
pProgressArg : POINTER) : longint;
TGDALDerivedPixelFunc = function(papoSources : PPOINTER; nSources : longint;
pData : POINTER; nBufXSize, nBufYSize : longint;
eSrcType : TGDALDataType;
eBufType : TGDALDataType;
nPixelSpace, nLineSpace : longint): TCPLErr;
//* -------------------------------------------------------------------- */
//* Define handle types related to various internal classes. */
//* -------------------------------------------------------------------- */
TGDALMajorObjectH = POINTER;
TGDALDatasetH = POINTER;
TGDALRasterBandH = POINTER;
TGDALDriverH = POINTER;
TGDALColorTableH = POINTER;
TGDALRasterAttributeTableH = POINTER;
PGDALRasterBandH = ^TGDALRasterBandH;
PGDALDatasetH = ^TGDALDatasetH;
PPGDALDatasetH = ^PGDALDatasetH;
const
//* ==================================================================== */
//* Registration/driver related. */
//* ==================================================================== */
DMD_SHORTNAME : PCHAR = 'DMD_SHORTNAME';
DMD_LONGNAME : PCHAR = 'DMD_LONGNAME';
DMD_HELPTOPIC : PCHAR = 'DMD_HELPTOPIC';
DMD_MIMETYPE : PCHAR = 'DMD_MIMETYPE';
DMD_EXTENSION : PCHAR = 'DMD_EXTENSION';
DMD_CREATIONOPTIONLIST : PCHAR = 'DMD_CREATIONOPTIONLIST';
DMD_CREATIONDATATYPES : PCHAR = 'DMD_CREATIONDATATYPES';
DCAP_CREATE : PCHAR = 'DCAP_CREATE';
DCAP_CREATECOPY : PCHAR = 'DCAP_CREATECOPY';
GDALMD_AREA_OR_POINT = 'AREA_OR_POINT';
GDALMD_AOP_AREA = 'Area';
GDALMD_AOP_POINT = 'Point';
CPLE_WrongFormat = 200;
GDAL_DMD_LONGNAME = 'DMD_LONGNAME';
GDAL_DMD_HELPTOPIC = 'DMD_HELPTOPIC';
GDAL_DMD_MIMETYPE = 'DMD_MIMETYPE';
GDAL_DMD_EXTENSION = 'DMD_EXTENSION';
GDAL_DMD_CREATIONOPTIONLIST = 'DMD_CREATIONOPTIONLIST';
GDAL_DMD_CREATIONDATATYPES = 'DMD_CREATIONDATATYPES';
GDAL_DCAP_CREATE = 'DCAP_CREATE';
GDAL_DCAP_CREATECOPY = 'DCAP_CREATECOPY';
GDAL_DCAP_VIRTUALIO = 'DCAP_VIRTUALIO';
//SRCVAL(papoSource, eSrcType, ii)
//SRCVAL - Macro which may be used by pixel functions to obtain a pixel from a source buffer.
GMF_ALL_VALID = $01;
GMF_PER_DATASET = $02;
GMF_ALPHA = $04;
GMF_NODATA = $08;
type
TGDAL_GCP = record
pszId : PCHAR;//Unique identifier, often numeric.
pszInfo : PCHAR;//Informational message or "".
dfGCPPixel : double;//Pixel (x) location of GCP on raster.
dfGCPLine : double;//Line (y) location of GCP on raster.
dfGCPX : double;//X position of GCP in georeferenced space.
dfGCPY : double;//Y position of GCP in georeferenced space.
dfGCPZ : double;//Elevation of GCP, or zero if not known.
end;
PGDAL_GCP = ^TGDAL_GCP;
TGDALColorEntry = record
c1 : shortint;
c2 : shortint;
c3 : shortint;
c4 : shortint;
end;
PGDALColorEntry = ^TGDALColorEntry;
TGDALRPCInfo = record
dfLINE_OFF : double;
dfSAMP_OFF : double;
dfLAT_OFF : double;
dfLONG_OFF : double;
dfHEIGHT_OFF : double;
dfLINE_SCALE : double;
dfSAMP_SCALE : double;
dfLAT_SCALE : double;
dfLONG_SCALE : double;
dfHEIGHT_SCALE : double;
adfLINE_NUM_COEFF : array[0..20] of double;
adfLINE_DEN_COEFF : array[0..20] of double;
adfSAMP_NUM_COEFF : array[0..20] of double;
adfSAMP_DEN_COEFF : array[0..20] of double;
dfMIN_LONG : double;
dfMIN_LAT : double;
dfMAX_LONG : double;
dfMAX_LAT : double;
end;
PGDALRPCInfo = ^TGDALRPCInfo;
implementation
end.
//
//'*****************************************************************************
//' Build 0135
//'
//' Project: GDAL Lazarus Bindings
//' Purpose: Types and Constants for OGR
//' Author: Frank Warmerdam, warmerdam@pobox.com
//' Lazarus Wrapper : Prajuab Riabroy
//'*****************************************************************************
//' Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
//'
//' Permission is hereby granted, free of charge, to any person obtaining a
//' copy of this software and associated documentation files (the "Software"),
//' to deal in the Software without restriction, including without limitation
//' the rights to use, copy, modify, merge, publish, distribute, sublicense,
//' and/or sell copies of the Software, and to permit persons to whom the
//' Software is furnished to do so, subject to the following conditions:
//'
//' The above copyright notice and this permission notice shall be included
//' in all copies or substantial portions of the Software.
//'
//' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//' OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
//' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//' DEALINGS IN THE SOFTWARE.
//'*****************************************************************************
unit ogr;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, gdal;
type
TOGRSpatialReferenceH = POINTER;
TOGRCoordinateTransformationH = POINTER;
TOGREnvelope = record
MinX : double;
MaxX : double;
MinY : double;
MaxY : double;
end;
TOGRErr = (OGRERR_NONE = 0,
OGRERR_NOT_ENOUGH_DATA = 1, //* not enough data to deserialize */
OGRERR_NOT_ENOUGH_MEMORY = 2,
OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3,
OGRERR_UNSUPPORTED_OPERATION = 4,
OGRERR_CORRUPT_DATA = 5,
OGRERR_FAILURE = 6,
OGRERR_UNSUPPORTED_SRS = 7,
OGRERR_INVALID_HANDLE = 8);
POGRErr = ^ TOGRErr;
TOGRwkbGeometryType = (wkbUnknown = 0,
wkbPoint = 1,
wkbLineString = 2,
wkbPolygon = 3,
wkbMultiPoint = 4,
wkbMultiLineString = 5,
wkbMultiPolygon = 6,
wkbGeometryCollection = 7,
wkbNone = 100,
wkbLinearRing = 101,
wkbPoint25D = $80000001,
wkbLineString25D = $80000002,
wkbPolygon25D = $80000003,
wkbMultiPoint25D = $80000004,
wkbMultiLineString25D = $80000005,
wkbMultiPolygon25D = $80000006,
wkbGeometryCollection25D = $80000007) ;
const
wkb25DBit = $80000000;
ogrZMarker = $21125711;
type
TOGRwkbByteOrder = (wkbXDR = 0, //* MSB/Sun/Motoroloa: Most Significant Byte First */
wkbNDR = 1); //* LSB/Intel/Vax: Least Significant Byte First */
TOGRFieldType = (OFTInteger = 0,
OFTIntegerList = 1,
OFTReal = 2,
OFTRealList = 3,
OFTString = 4,
OFTStringList = 5,
OFTWideString = 6,
OFTWideStringList = 7,
OFTBinary = 8,
OFTDate = 9,
OFTTime = 10,
OFTDateTime = 11,
OFTMaxType = 11);
TOGRJustification = (OJUndefined = 0,
OJLeft = 1,
OJRight = 2);
const
OGRNullFID = -1;
OGRUnsetMarker = -21121;
function OGRGeometryTypeToName(eType : TOGRwkbGeometryType) : PCHAR; stdcall; external GDALLib name 'OGRGeometryTypeToName';
function OGRMergeGeometryTypes(eMain, eExtra : TOGRwkbGeometryType) : TOGRwkbGeometryType; stdcall; external GDALLib name 'OGRMergeGeometryTypes';
type
POGRField = ^TOGRField;
TOGRField = record
case longint of
0 : ( Integer : longint );
1 : ( Real : double);
2 : ( _String : Pchar );
3 : ( IntegerList : record
nCount : longint;
paList : Plongint;
end );
4 : ( TRealList : record
nCount : longint;
paList : PDOUBLE;
end );
5 : ( TStringList : record
nCount : longint;
paList : PPCHAR;
end );
6 : ( TBinary : record
nCount : longint;
paData : PGByte;
end );
7 : ( TSet : record
nMarker1 : longint;
nMarker2 : longint;
end );
8 : ( TDate : record
Year : TGInt16;
Month : TGByte;
Day : TGByte;
Hour : TGByte;
Minute : TGByte;
Second : TGByte;
TZFlag : TGByte;
end );
end;
function OGRParseDate(pszInput : PCHAR; psOutput : POGRField;
nOptions : longint) : longint; stdcall; external GDALLib name 'OGRParseDate';
//* -------------------------------------------------------------------- */
//* Constants from ogrsf_frmts.h for capabilities. */
//* -------------------------------------------------------------------- */
const
OLCRandomRead = 'RandomRead';
OLCSequentialWrite = 'SequentialWrite';
OLCRandomWrite = 'RandomWrite';
OLCFastSpatialFilter = 'FastSpatialFilter';
OLCFastFeatureCount = 'FastFeatureCount';
OLCFastGetExtent = 'FastGetExtent';
OLCCreateField = 'CreateField';
OLCTransactions = 'Transactions';
OLCDeleteFeature = 'DeleteFeature';
OLCFastSetNextByIndex = 'FastSetNextByIndex';
OLCStringsAsUTF8 = 'StringsAsUTF8';
ODsCCreateLayer = 'CreateLayer';
ODsCDeleteLayer = 'DeleteLayer';
ODrCCreateDataSource = 'CreateDataSource';
ODrCDeleteDataSource = 'DeleteDataSource';
type
Togr_style_tool_class_id = (OGRSTCNone = 0,
OGRSTCPen = 1,
OGRSTCBrush = 2,
OGRSTCSymbol = 3,
OGRSTCLabel = 4,
OGRSTCVector = 5);
Togr_style_tool_param_pen_id = (OGRSTPenColor = 0,
OGRSTPenWidth = 1,
OGRSTPenPattern = 2,
OGRSTPenId = 3,
OGRSTPenPerOffset = 4,
OGRSTPenCap = 5,
OGRSTPenJoin = 6,
OGRSTPenPriority = 7,
OGRSTPenLast = 8);
Togr_style_tool_param_symbol_id = (OGRSTSymbolId = 0,
OGRSTSymbolAngle = 1,
OGRSTSymbolColor = 2,
OGRSTSymbolSize = 3,
OGRSTSymbolDx = 4,
OGRSTSymbolDy = 5,
OGRSTSymbolStep = 6,
OGRSTSymbolPerp = 7,
OGRSTSymbolOffset = 8,
OGRSTSymbolPriority = 9,
OGRSTSymbolFontName = 10,
OGRSTSymbolOColor = 11,
OGRSTSymbolLast = 12);
Togr_style_tool_units_id = (OGRSTUGround = 0,
OGRSTUPixel = 1,
OGRSTUPoints = 2,
OGRSTUMM = 3,
OGRSTUCM = 4,
OGRSTUInches = 5);
Togr_style_tool_param_brush_id = (OGRSTBrushFColor = 0,
OGRSTBrushBColor = 1,
OGRSTBrushId = 2,
OGRSTBrushAngle = 3,
OGRSTBrushSize = 4,
OGRSTBrushDx = 5,
OGRSTBrushDy = 6,
OGRSTBrushPriority = 7,
OGRSTBrushLast = 8);
Togr_style_tool_param_label_id = (OGRSTLabelFontName = 0,
OGRSTLabelSize = 1,
OGRSTLabelTextString = 2,
OGRSTLabelAngle = 3,
OGRSTLabelFColor = 4,
OGRSTLabelBColor = 5,
OGRSTLabelPlacement = 6,
OGRSTLabelAnchor = 7,
OGRSTLabelDx = 8,
OGRSTLabelDy = 9,
OGRSTLabelPerp = 10,
OGRSTLabelBold = 11,
OGRSTLabelItalic = 12,
OGRSTLabelUnderline = 13,
OGRSTLabelPriority = 14,
OGRSTLabelStrikeout = 15,
OGRSTLabelStretch = 16,
OGRSTLabelAdjHor = 17,
OGRSTLabelAdjVert = 18,
OGRSTLabelHColor = 19,
OGRSTLabelOColor = 20,
OGRSTLabelLast = 21);
TOGRSTUnitId = Togr_style_tool_units_id;
TOGRSTPenParam = Togr_style_tool_param_pen_id;
TOGRSTBrushParam = Togr_style_tool_param_brush_id;
TOGRSTSymbolParam = Togr_style_tool_param_symbol_id;
TOGRSTClassId = Togr_style_tool_class_id;
TOGRSTLabelParam = Togr_style_tool_param_label_id;
Pogr_style_tool_class_id = ^Togr_style_tool_class_id;
Pogr_style_tool_param_brush_id = ^Togr_style_tool_param_brush_id;
Pogr_style_tool_param_label_id = ^Togr_style_tool_param_label_id;
Pogr_style_tool_param_pen_id = ^Togr_style_tool_param_pen_id;
Pogr_style_tool_param_symbol_id = ^Togr_style_tool_param_symbol_id;
Pogr_style_tool_units_id = ^Togr_style_tool_units_id;
POGRSTBrushParam = ^TOGRSTBrushParam;
POGRSTClassId = ^TOGRSTClassId;
POGRSTLabelParam = ^TOGRSTLabelParam;
POGRSTPenParam = ^TOGRSTPenParam;
POGRSTSymbolParam = ^TOGRSTSymbolParam;
POGRSTUnitId = ^TOGRSTUnitId;
TOGRAxisOrientation = (OAO_Other = 0,
OAO_North = 1,
OAO_South = 2,
OAO_East = 3,
OAO_West = 4,
OAO_Up = 5,
OAO_Down = 6) ;
function OSRAxisEnumToName(eOrientation : TOGRAxisOrientation
) : PCHAR; cdecl; external GDALLib name 'OSRAxisEnumToName';
//* -------------------------------------------------------------------- */
//* Datum types (corresponds to CS_DatumType). */
//* -------------------------------------------------------------------- */
type
TOGRDatumType = (
ODT_HD_Min = 1000,
ODT_HD_Other = 1000,
ODT_HD_Classic = 1001,
ODT_HD_Geocentric = 1002,
ODT_HD_Max = 1999,
ODT_VD_Min = 2000,
ODT_VD_Other = 2000,
ODT_VD_Orthometric = 2001,
ODT_VD_Ellipsoidal = 2002,
ODT_VD_AltitudeBarometric = 2003,
ODT_VD_Normal = 2004,
ODT_VD_GeoidModelDerived = 2005,
ODT_VD_Depth = 2006,
ODT_VD_Max = 2999,
ODT_LD_Min = 10000,
ODT_LD_Max = 32767);
const
//SRS_WKT_WGS84 : PCHAR = 'GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]]';
//* ==================================================================== */
//* Some "standard" strings. */
//* ==================================================================== */
SRS_PT_ALBERS_CONIC_EQUAL_AREA = 'Albers_Conic_Equal_Area';
SRS_PT_AZIMUTHAL_EQUIDISTANT = 'Azimuthal_Equidistant';
SRS_PT_CASSINI_SOLDNER = 'Cassini_Soldner';
SRS_PT_CYLINDRICAL_EQUAL_AREA = 'Cylindrical_Equal_Area';
SRS_PT_BONNE = 'Bonne';
SRS_PT_ECKERT_I = 'Eckert_I';
SRS_PT_ECKERT_II = 'Eckert_II';
SRS_PT_ECKERT_III = 'Eckert_III';
SRS_PT_ECKERT_IV = 'Eckert_IV';
SRS_PT_ECKERT_V = 'Eckert_V';
SRS_PT_ECKERT_VI = 'Eckert_VI';
SRS_PT_EQUIDISTANT_CONIC = 'Equidistant_Conic';
SRS_PT_EQUIRECTANGULAR = 'Equirectangular';
SRS_PT_GALL_STEREOGRAPHIC = 'Gall_Stereographic';
SRS_PT_GAUSSSCHREIBERTMERCATOR = 'Gauss_Schreiber_Transverse_Mercator';
SRS_PT_GEOSTATIONARY_SATELLITE = 'Geostationary_Satellite';
SRS_PT_GOODE_HOMOLOSINE = 'Goode_Homolosine';
SRS_PT_GNOMONIC = 'Gnomonic';
SRS_PT_HOTINE_OBLIQUE_MERCATOR = 'Hotine_Oblique_Mercator';
SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN=
'Hotine_Oblique_Mercator_Two_Point_Natural_Origin';
SRS_PT_LABORDE_OBLIQUE_MERCATOR = 'Laborde_Oblique_Mercator';
SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP = 'Lambert_Conformal_Conic_1SP';
SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP = 'Lambert_Conformal_Conic_2SP';
SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM =
'Lambert_Conformal_Conic_2SP_Belgium';
SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA =
'Lambert_Azimuthal_Equal_Area';
SRS_PT_MERCATOR_1SP = 'Mercator_1SP';
SRS_PT_MERCATOR_2SP = 'Mercator_2SP';
SRS_PT_MILLER_CYLINDRICAL = 'Miller_Cylindrical';
SRS_PT_MOLLWEIDE = 'Mollweide';
SRS_PT_NEW_ZEALAND_MAP_GRID = 'New_Zealand_Map_Grid';
SRS_PT_OBLIQUE_STEREOGRAPHIC = 'Oblique_Stereographic';
SRS_PT_ORTHOGRAPHIC = 'Orthographic';
SRS_PT_POLAR_STEREOGRAPHIC = 'Polar_Stereographic';
SRS_PT_POLYCONIC='Polyconic';
SRS_PT_ROBINSON = 'Robinson';
SRS_PT_SINUSOIDAL = 'Sinusoidal';
SRS_PT_STEREOGRAPHIC = 'Stereographic';
SRS_PT_SWISS_OBLIQUE_CYLINDRICAL = 'Swiss_Oblique_Cylindrical';
SRS_PT_TRANSVERSE_MERCATOR = 'Transverse_Mercator';
SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED
= 'Transverse_Mercator_South_Orientated';
//* special mapinfo variants on Transverse Mercator */
SRS_PT_TRANSVERSE_MERCATOR_MI_21 =
'Transverse_Mercator_MapInfo_21';
SRS_PT_TRANSVERSE_MERCATOR_MI_22 =
'Transverse_Mercator_MapInfo_22';
SRS_PT_TRANSVERSE_MERCATOR_MI_23 =
'Transverse_Mercator_MapInfo_23';
SRS_PT_TRANSVERSE_MERCATOR_MI_24 =
'Transverse_Mercator_MapInfo_24';
SRS_PT_TRANSVERSE_MERCATOR_MI_25 =
'Transverse_Mercator_MapInfo_25';
SRS_PT_TUNISIA_MINING_GRID =
'Tunisia_Mining_Grid';
SRS_PT_TWO_POINT_EQUIDISTANT =
'Two_Point_Equidistant';
SRS_PT_VANDERGRINTEN = 'VanDerGrinten';
SRS_PT_KROVAK = 'Krovak';
SRS_PT_IMW_POLYCONIC = 'International_Map_of_the_World_Polyconic';
SRS_PT_WAGNER_I = 'Wagner_I';
SRS_PT_WAGNER_II = 'Wagner_II';
SRS_PT_WAGNER_III = 'Wagner_III';
SRS_PT_WAGNER_IV = 'Wagner_IV';
SRS_PT_WAGNER_V = 'Wagner_V';
SRS_PT_WAGNER_VI = 'Wagner_VI';
SRS_PT_WAGNER_VII = 'Wagner_VII';
SRS_PP_CENTRAL_MERIDIAN = 'central_meridian';
SRS_PP_SCALE_FACTOR = 'scale_factor';
SRS_PP_STANDARD_PARALLEL_1 = 'standard_parallel_1';
SRS_PP_STANDARD_PARALLEL_2 = 'standard_parallel_2';
SRS_PP_PSEUDO_STD_PARALLEL_1 = 'pseudo_standard_parallel_1';
SRS_PP_LONGITUDE_OF_CENTER = 'longitude_of_center';
SRS_PP_LATITUDE_OF_CENTER = 'latitude_of_center';
SRS_PP_LONGITUDE_OF_ORIGIN = 'longitude_of_origin';
SRS_PP_LATITUDE_OF_ORIGIN = 'latitude_of_origin';
SRS_PP_FALSE_EASTING = 'false_easting';
SRS_PP_FALSE_NORTHING = 'false_northing';
SRS_PP_AZIMUTH = 'azimuth';
SRS_PP_LONGITUDE_OF_POINT_1 = 'longitude_of_point_1';
SRS_PP_LATITUDE_OF_POINT_1 = 'latitude_of_point_1';
SRS_PP_LONGITUDE_OF_POINT_2 = 'longitude_of_point_2';
SRS_PP_LATITUDE_OF_POINT_2 = 'latitude_of_point_2';
SRS_PP_LONGITUDE_OF_POINT_3 = 'longitude_of_point_3';
SRS_PP_LATITUDE_OF_POINT_3 = 'latitude_of_point_3';
SRS_PP_RECTIFIED_GRID_ANGLE = 'rectified_grid_angle';
SRS_PP_LANDSAT_NUMBER = 'landsat_number';
SRS_PP_PATH_NUMBER = 'path_number';
SRS_PP_PERSPECTIVE_POINT_HEIGHT = 'perspective_point_height';
SRS_PP_SATELLITE_HEIGHT = 'satellite_height';
SRS_PP_FIPSZONE = 'fipszone';
SRS_PP_ZONE = 'zone';
SRS_PP_LATITUDE_OF_1ST_POINT = 'Latitude_Of_1st_Point';
SRS_PP_LONGITUDE_OF_1ST_POINT = 'Longitude_Of_1st_Point';
SRS_PP_LATITUDE_OF_2ND_POINT = 'Latitude_Of_2nd_Point';
SRS_PP_LONGITUDE_OF_2ND_POINT = 'Longitude_Of_2nd_Point';
SRS_UL_METER = 'Meter';
SRS_UL_FOOT = 'Foot (International)'; //* or just 'FOOT'? */
SRS_UL_FOOT_CONV = '0.3048';
SRS_UL_US_FOOT = 'Foot_US'; //* or 'US survey foot' from EPSG */
SRS_UL_US_FOOT_CONV = '0.3048006096012192';
SRS_UL_NAUTICAL_MILE = 'Nautical Mile';
SRS_UL_NAUTICAL_MILE_CONV = '1852.0';
SRS_UL_LINK = 'Link'; //* Based on US Foot */
SRS_UL_LINK_CONV = '0.20116684023368047';
SRS_UL_CHAIN = 'Chain'; //* based on US Foot */
SRS_UL_CHAIN_CONV = '20.116684023368047';
SRS_UL_ROD = 'Rod'; //* based on US Foot */
SRS_UL_ROD_CONV = '5.02921005842012';
SRS_UA_DEGREE = 'degree';
SRS_UA_DEGREE_CONV = '0.0174532925199433';
SRS_UA_RADIAN = 'radian';
SRS_PM_GREENWICH = 'Greenwich';
SRS_DN_NAD27 = 'North_American_Datum_1927';
SRS_DN_NAD83 = 'North_American_Datum_1983';
SRS_DN_WGS72 = 'WGS_1972';
SRS_DN_WGS84 = 'WGS_1984';
SRS_WGS84_SEMIMAJOR = 6378137.0;
SRS_WGS84_INVFLATTENING = 298.257223563;
implementation
end.
สุดท้ายเป็นไฟล์ ogrcore.pas
{'*****************************************************************************
' Build 0135
'
' Project: GDAL Lazarus Bindings
' Purpose: OGR Lazarus internal support functions.
' Author: Frank Warmerdam, warmerdam@pobox.com
' Lazarus Wrapper : Prajuab Riabroy
'*****************************************************************************
' Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
'
' Permission is hereby granted, free of charge, to any person obtaining a
' copy of this software and associated documentation files (the "Software"),
' to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense,
' and/or sell copies of the Software, and to permit persons to whom the
' Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included
' in all copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
' OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'*****************************************************************************
}
unit ogrcore;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, gdal, ogr;
procedure OGRFree(p : POINTER); cdecl; external GDALLib name 'OGRFree';
{$IFDEF MSWINDOWS}
function OSRNewSpatialReference(const WKT : PCHAR
) : TOGRSpatialReferenceH; stdcall; external GDALLib name '_OSRNewSpatialReference@4';
function OSRCloneGeogCS(const Handle : TOGRSpatialReferenceH
) : TOGRSpatialReferenceH; stdcall; external GDALLib name '_OSRCloneGeogCS@4';
function OSRClone(const Handle : TOGRSpatialReferenceH
) : TOGRSpatialReferenceH ; stdcall; external GDALLib name '_OSRClone@4';
procedure OSRDestroySpatialReference (const Handle : TOGRSpatialReferenceH
); stdcall; external GDALLib name '_OSRDestroySpatialReference@4';
{$ENDIF}
{$IFDEF LINUX}
function OSRNewSpatialReference(const WKT : PCHAR
) : TOGRSpatialReferenceH; cdecl; external GDALLib name 'OSRNewSpatialReference';
function OSRCloneGeogCS(const Handle : TOGRSpatialReferenceH
) : TOGRSpatialReferenceH; cdecl; external GDALLib name 'OSRCloneGeogCS';
function OSRClone(const Handle : TOGRSpatialReferenceH
) : TOGRSpatialReferenceH ; cdecl; external GDALLib name 'OSRClone';
procedure OSRDestroySpatialReference (const Handle : TOGRSpatialReferenceH
); cdecl; external GDALLib name 'OSRDestroySpatialReference';
{$ENDIF}
function OSRReference(hSRS : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRReference';
function OSRDereference(hSRS : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRDereference';
procedure OSRRelease(hSRS : TOGRSpatialReferenceH
); cdecl; external GDALLib name 'OSRRelease';
function OSRValidate(hSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRValidate';
function OSRFixupOrdering(hSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRFixupOrdering';
function OSRFixup(hSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRFixup';
function OSRStripCTParms(hSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRStripCTParms';
{$IFDEF MSWINDOWS}
function OSRImportFromEPSG(hSRS : TOGRSpatialReferenceH;
EPSGCode : longint
) : TOGRErr; stdcall; external GDALLib name '_OSRImportFromEPSG@8';
{$ENDIF}
{$IFDEF LINUX}
function OSRImportFromEPSG(hSRS : TOGRSpatialReferenceH;
EPSGCode : longint
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromEPSG';
{$ENDIF}
function OSRImportFromWkt(hSRS : TOGRSpatialReferenceH;
ppszInput : PPCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromWkt';
function OSRImportFromProj4(hSRS : TOGRSpatialReferenceH;
pszProj4 : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromProj4';
function OSRImportFromESRI(hSRS : TOGRSpatialReferenceH;
papszPrj : PPCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromESRI';
function OSRImportFromPCI(hSRS : TOGRSpatialReferenceH; pszProj : PCHAR;
pszUnits : PCHAR; padfPrjParams : PDOUBLE
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromPCI';
function OSRImportFromUSGS(hSRS : TOGRSpatialReferenceH; iProjsys : longint;
iZone : longint; padfPrjParams : PDOUBLE;
iDatum : longint
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromUSGS';
function OSRImportFromXML(hSRS : TOGRSpatialReferenceH;
pszXML : PCHAR) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromXML';
function OSRImportFromMICoordSys(hSRS : TOGRSpatialReferenceH;
pszCoordSys : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromMICoordSys';
function OSRImportFromUrl(hSRS : TOGRSpatialReferenceH;
pszUrl : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRImportFromUrl';
function OSRExportToWkt(hSRS : TOGRSpatialReferenceH;
ppszReturn : PPCHAR) : TOGRErr; stdcall; external GDALLib name '_OSRExportToWkt@8';
function OSRExportToPrettyWkt(hSRS : TOGRSpatialReferenceH;
ppszReturn : PPCHAR;
bSimplify: longint) : TOGRErr; stdcall; external GDALLib name '_OSRExportToPrettyWkt@12';
function OSRExportToProj4(hSRS : TOGRSpatialReferenceH;
ppszReturn : PPCHAR) : TOGRErr; stdcall; external GDALLib name '_OSRExportToProj4@8';
function OSRExportToPCI(hSRS : TOGRSpatialReferenceH; ppszProj : PPCHAR;
ppszUnits : PPCHAR;
ppadfPrjParams : PPDOUBLE
) : TOGRErr; cdecl; external GDALLib name 'OSRExportToPCI';
function OSRExportToUSGS(hSRS : TOGRSpatialReferenceH; piProjSys : PINTEGER;
piZone : PLONGINT;
ppadfPrjParams : PPDOUBLE;
piDatum : PLONGINT
) : TOGRErr; cdecl; external GDALLib name 'OSRExportToUSGS';
function OSRExportToXML(hSRS : TOGRSpatialReferenceH; ppszRawXML : PPCHAR;
pszDialect : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRExportToXML';
function OSRExportToMICoordSys(hSRS : TOGRSpatialReferenceH;
ppszReturn : PPCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRExportToMICoordSys';
function OSRMorphToESRI(hSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRMorphToESRI';
function OSRMorphFromESRI(hSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRMorphFromESRI';
{$IFDEF MSWINDOWS}
function OSRSetAttrValue(hSRS : TOGRSpatialReferenceH;
pszNodePath : PCHAR;
pszNewNodeValue : PCHAR
) : TOGRErr; stdcall; external GDALLib name '_OSRSetAttrValue@12';
function OSRGetAttrValue(hSRS : TOGRSpatialReferenceH;
pszName : PCHAR;
iChild : longint(* = 0 *)
) : PCHAR; stdcall; external GDALLib name '_OSRGetAttrValue@12';
{$ENDIF}
{$IFDEF LINUX}
function OSRSetAttrValue(hSRS : TOGRSpatialReferenceH;
pszNodePath : PCHAR;
pszNewNodeValue : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRSetAttrValue';
function OSRGetAttrValue(hSRS : TOGRSpatialReferenceH;
pszName : PCHAR;
iChild : longint(* = 0 *)
) : PCHAR; cdecl; external GDALLib name 'OSRGetAttrValue';
{$ENDIF}
function OSRSetAngularUnits(hSRS : TOGRSpatialReferenceH; pszUnits : PCHAR;
dfInRadians : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetAngularUnits';
function OSRGetAngularUnits(hSRS : TOGRSpatialReferenceH;
ppszName : PPCHAR
) : double; cdecl; external GDALLib name 'OSRGetAngularUnits';
function OSRSetLinearUnits(hSRS : TOGRSpatialReferenceH; pszUnits : PCHAR;
dfInMeters : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLinearUnits';
function OSRSetLinearUnitsAndUpdateParameters(hSRS : TOGRSpatialReferenceH;
pszUnits : PCHAR;
dfInMeters : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLinearUnitsAndUpdateParameters';
function OSRGetLinearUnits(hSRS : TOGRSpatialReferenceH;
ppszName : PPCHAR
) : double; cdecl; external GDALLib name 'OSRGetLinearUnits';
function OSRGetPrimeMeridian(hSRS : TOGRSpatialReferenceH;
ppszName : PPCHAR
) : double; cdecl; external GDALLib name 'OSRGetPrimeMeridian';
function OSRIsGeographic(hSRS : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRIsGeographic';
function OSRIsLocal(hSRS : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRIsLocal';
function OSRIsProjected(hSRS : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRIsProjected';
function OSRIsSameGeogCS(hSRS1 : TOGRSpatialReferenceH;
hSRS2 : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRIsSameGeogCS';
function OSRIsSame(hSRS1 : TOGRSpatialReferenceH;
hSRS2 : TOGRSpatialReferenceH
) : longint; cdecl; external GDALLib name 'OSRIsSame';
function OSRSetLocalCS(hSRS : TOGRSpatialReferenceH;
pszName : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLocalCS';
function OSRSetProjCS(hSRS : TOGRSpatialReferenceH;
pszName : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRSetProjCS';
function OSRSetWellKnownGeogCS(hSRS : TOGRSpatialReferenceH;
pszName : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRSetWellKnownGeogCS';
function OSRSetFromUserInput(hSRS : TOGRSpatialReferenceH;
pszDef : PCHAR
): TOGRErr; stdcall; external GDALLib name '_OSRSetFromUserInput@8';
function OSRCopyGeogCSFrom(hSRS : TOGRSpatialReferenceH;
hSrcSRS : TOGRSpatialReferenceH
) : TOGRErr; cdecl; external GDALLib name 'OSRCopyGeogCSFrom';
function OSRSetTOWGS84(hSRS : TOGRSpatialReferenceH;
dfDX, dfDY,
dfDZ, dfEX,
dfEY, dfEZ,
dfPPM : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetTOWGS84';
function OSRGetTOWGS84(hSRS : TOGRSpatialReferenceH; padfCoeff : PDOUBLE;
nCoeffCount : longint) : TOGRErr; cdecl; external GDALLib name 'OSRGetTOWGS84';
function OSRSetGeogCS(hSRS : TOGRSpatialReferenceH;
pszGeogName, pszDatumName, pszEllipsoidName : PCHAR;
dfSemiMajor, dfInvFlattening : double;
pszPMName : PCHAR; (* = NULL *)
dfPMOffset : double; (* = 0.0 *)
pszUnits : PCHAR;(* = NULL *)
dfConvertToRadians : double(* = 0.0 *)
) : TOGRErr; cdecl; external GDALLib name 'OSRSetGeogCS';
function OSRGetSemiMajor(hSRS : TOGRSpatialReferenceH;
pnErr : POGRErr
) : double; cdecl; external GDALLib name 'OSRGetSemiMajor';
function OSRGetSemiMinor(hSRS : TOGRSpatialReferenceH;
pnErr : POGRErr
) : double; cdecl; external GDALLib name 'OSRGetSemiMinor';
function OSRGetInvFlattening(hSRS : TOGRSpatialReferenceH;
pnErr : POGRErr
) : double; cdecl; external GDALLib name 'OSRGetInvFlattening';
function OSRSetAuthority(hSRS : TOGRSpatialReferenceH;
pszTargetKey : PCHAR;
pszAuthority : PCHAR;
nCode : longint
) : TOGRErr; cdecl; external GDALLib name 'OSRSetAuthority';
function OSRGetAuthorityCode(hSRS : TOGRSpatialReferenceH;
pszTargetKey : PCHAR
) : PCHAR; cdecl; external GDALLib name 'OSRGetAuthorityCode';
function OSRGetAuthorityName(hSRS : TOGRSpatialReferenceH;
pszTargetKey : PCHAR
) : PCHAR; cdecl; external GDALLib name 'OSRGetAuthorityName';
function OSRSetProjection(hSRS : TOGRSpatialReferenceH;
pszProjection : PCHAR
) : TOGRErr; cdecl; external GDALLib name 'OSRSetProjection';
function OSRSetProjParm(hSRS : TOGRSpatialReferenceH;
pszParmName : PCHAR;
dfValue : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetProjParm';
function OSRGetProjParm(hSRS : TOGRSpatialReferenceH;
pszParmName : PCHAR;
dfDefault : double;
pnErr : POGRErr
) : double; cdecl; external GDALLib name 'OSRGetProjParm';
function OSRSetNormProjParm(hSRS : TOGRSpatialReferenceH;
pszParmName : PCHAR;
dfValue : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetNormProjParm';
function OSRGetNormProjParm(hSRS : TOGRSpatialReferenceH;
pszParmName : PCHAR;
dfDefault : double;
pnErr : POGRErr
) : double; cdecl; external GDALLib name 'OSRGetNormProjParm';
function OSRSetUTM(hSRS : TOGRSpatialReferenceH;
nZone : longint;
bNorth : longint
) : TOGRErr; cdecl; external GDALLib name 'OSRSetUTM';
function OSRGetUTMZone(hSRS : TOGRSpatialReferenceH;
pbNorth : PINTEGER
) : longint; cdecl; external GDALLib name 'OSRGetUTMZone';
//** Albers Conic Equal Area */
function OSRSetACEA(hSRS : TOGRSpatialReferenceH;
dfStdP1, dfStdP2,
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetACEA';
//** Azimuthal Equidistant */
function OSRSetAE(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetACEA';
//** Bonne */
function OSRSetBonne(hSRS : TOGRSpatialReferenceH;
dfStandardParallel, dfCentralMeridian,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetBonne';
//** Cylindrical Equal Area */
function OSRSetCEA(hSRS : TOGRSpatialReferenceH;
dfStdP1, dfCentralMeridian,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetCEA';
//** Cassini-Soldner */
function OSRSetCS(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetCS';
//** Equidistant Conic */
function OSRSetEC(hSRS : TOGRSpatialReferenceH;
dfStdP1, dfStdP2,
dfCenterLat, dCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetEC';
///** Eckert I-VI */
function OSRSetEckert(hSRS : TOGRSpatialReferenceH;
nVariation : longint;
dfCentralMeridian,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetEckert';
//** Eckert IV */
function OSRSetEckertIV(hSRS : TOGRSpatialReferenceH;
dfCentralMeridian,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetEckertIV';
//** Eckert VI */
function OSRSetEckertVI(hSRS : TOGRSpatialReferenceH;
dfCentralMeridian,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetEckertVI';
//** Equirectangular */
function OSRSetEquirectangular(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetEquirectangular';
//** Equirectangular generalized form */
function OSRSetEquirectangular2(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfPseudoStdParallel1,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetEquirectangular2';
//** Gall Stereograpic */
function OSRSetGS(hSRS : TOGRSpatialReferenceH;
dfCentralMeridian,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetGS';
//** Goode Homolosine */
function OSRSetGH(hSRS : TOGRSpatialReferenceH;
dfCentralMeridian,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetGH';
//** GEOS - Geostationary Satellite View */
function OSRSetGEOS(hSRS : TOGRSpatialReferenceH;
dfCentralMeridian, dfSatelliteHeight,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetGEOS';
//** Gauss Schreiber Transverse Mercator */
function OSRSetGaussSchreiberTMercator(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetGaussSchreiberTMercator';
//** Gnomonic */
function OSRSetGnomonic(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetGnomonic';
//** Hotine Oblique Mercator using azimuth angle */
function OSRSetHOM(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfAzimuth, dfRectToSkew,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetHOM';
//** Hotine Oblique Mercator using two points on centerline */
function OSRSetHOM2PNO(hSRS : TOGRSpatialReferenceH;
dfCenterLat,
dfLat1, dfLong1,
dfLat2, dfLong2,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetHOM2PNO';
//** International Map of the World Polyconic */
function OSRSetIWMPolyconic(hSRS : TOGRSpatialReferenceH;
dfLat1, dfLat2,
dfCenterLong,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetIWMPolyconic';
///** Krovak Oblique Conic Conformal */
function OSRSetKrovak(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfAzimuth, dfPseudoStdParallelLat,
dfScale,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetKrovak';
//** Lambert Azimuthal Equal-Area */
function OSRSetLAEA(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLAEA';
//** Lambert Conformal Conic */
function OSRSetLCC(hSRS : TOGRSpatialReferenceH;
dfStdP1, dfStdP2,
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLCC';
//** Lambert Conformal Conic 1SP */
function OSRSetLCC1SP(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLCC1SP';
//** Lambert Conformal Conic (Belgium) */
function OSRSetLCCB(hSRS : TOGRSpatialReferenceH;
dfStdP1, dfStdP2,
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetLCCB';
//** Miller Cylindrical */
function OSRSetMC(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetMC';
//** Mercator */
function OSRSetMercator(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetMercator';
//** Mollweide */
function OSRSetMollweide(hSRS : TOGRSpatialReferenceH;
dfCentralMeridian,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetMollweide';
//** New Zealand Map Grid */
function OSRSetNZMG(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetNZMG';
//** Oblique Stereographic */
function OSRSetOS(hSRS : TOGRSpatialReferenceH;
dfOriginLat, dfCMeridian,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetOS';
//** Orthographic */
function OSRSetOrthographic(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetOrthographic';
//** Polyconic */
function OSRSetPolyconic(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetPolyconic';
//** Polar Stereographic */
function OSRSetPS(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetPS';
//** Robinson */
function OSRSetRobinson(hSRS : TOGRSpatialReferenceH;
dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetRobinson';
//** Sinusoidal */
function OSRSetSinusoidal(hSRS : TOGRSpatialReferenceH;
dfCenterLong,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetSinusoidal';
//** Stereographic */
function OSRSetStereographic(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetStereographic';
//** Swiss Oblique Cylindrical */
function OSRSetSOC(hSRS : TOGRSpatialReferenceH;
dfLatitudeOfOrigin, dfCentralMeridian,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetSOC';
//** Transverse Mercator */
function OSRSetTM(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetTM';
//** Transverse Mercator variant */
function OSRSetTMVariant(hSRS : TOGRSpatialReferenceH;
pszVariantName : PCHAR;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetTMVariant';
//** Tunesia Mining Grid */
function OSRSetTMG(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetTMG';
//** Transverse Mercator (South Oriented) */
function OSRSetTMSO(hSRS : TOGRSpatialReferenceH;
dfCenterLat, dfCenterLong,
dfScale,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetTMSO';
//** VanDerGrinten */
function OSRSetVDG(hSRS : TOGRSpatialReferenceH;
dfCenterLong,
dfFalseEasting, dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetVDG';
//** Wagner I -- VII */
function OSRSetWagner(hSRS : TOGRSpatialReferenceH; nVariation : longint;
dfFalseEasting,
dfFalseNorthing : double
) : TOGRErr; cdecl; external GDALLib name 'OSRSetWagner';
procedure OSRCleanup; cdecl; external GDALLib name 'OSRCleanup';
//* -------------------------------------------------------------------- */
//* Projection transform dictionary query. */
//* -------------------------------------------------------------------- */
function OPTGetProjectionMethods : PPCHAR; cdecl; external GDALLib name 'OPTGetProjectionMethods';
function OPTGetParameterList(pszProjectionMethod : PCHAR;
ppszUserName : PPCHAR
) : PPCHAR; cdecl; external GDALLib name 'OPTGetParameterList';
function OPTGetParameterInfo(pszProjectionMethod : PCHAR;
pszParameterName : PCHAR;
ppszUserName : PPCHAR;
ppszType : PPCHAR;
pdfDefaultValue : PDOUBLE
) : longint; cdecl; external GDALLib name 'OPTGetParameterInfo';
{$IFDEF MSWINDOWS}
function OCTNewCoordinateTransformation (hSourceSRS : TOGRCoordinateTransformationH;
hTargetSRS : TOGRCoordinateTransformationH
) : TOGRCoordinateTransformationH ;
stdcall; external GDALLib name '_OCTNewCoordinateTransformation@8';
procedure OCTDestroyCoordinateTransformation (const Handle : TOGRCoordinateTransformationH
); stdcall; external GDALLib name '_OCTDestroyCoordinateTransformation@4';
function OCTTransformEx (const Handle : TOGRCoordinateTransformationH; const PointCount : longint;
X, Y, Z : PDOUBLE;
pSuccess : PINTEGER
) : longint; stdcall; external GDALLib name '_OCTTransformEx@24';
function OCTTransform (const Handle : TOGRCoordinateTransformationH; const PointCount : longint;
X, Y, Z : PDOUBLE
) : longint; stdcall; external GDALLib name '_OCTTransform@20';
{$ENDIF}
{$IFDEF LINUX}
function OCTNewCoordinateTransformation (hSourceSRS : TOGRCoordinateTransformationH;
hTargetSRS : TOGRCoordinateTransformationH
) : TOGRCoordinateTransformationH ;
cdecl; external GDALLib name 'OCTNewCoordinateTransformation';
procedure OCTDestroyCoordinateTransformation (const Handle : TOGRCoordinateTransformationH
); stdcall; external GDALLib name '_OCTDestroyCoordinateTransformation@4';
function OCTTransformEx (const Handle : TOGRCoordinateTransformationH; const PointCount : longint;
X, Y, Z : PDOUBLE;
pSuccess : PINTEGER
) : longint; cdecl; external GDALLib name 'OCTTransformEx';
function OCTTransform (const Handle : TOGRCoordinateTransformationH; const PointCount : longint;
X, Y, Z : PDOUBLE
) : longint; cdecl; external GDALLib name 'OCTTransform';
{$ENDIF}
implementation
end.
เริ่มโครงการโปรแกรมคำนวณค่าพิกัดด้วย Lazarus
เมื่อรัน Lazarus ลองเปิด Project ชื่อ UTM2LatLong.lpi จะเห็นหน้าตาของโปรแกรมที่ผมเขียนไว้ดังรูปด้านล่าง
เปิดโครงการโปรแกรมแปลงพิกัด
โปรแกรมนี้มีฟอร์มอยู่ 1 ฟอร์มเท่านั้น ผมวาง combobox ซึ่งเก็บชื่อ datum ซึ่งในโปรแกรมตัวอย่างนี้ผมเขียนไว้แค่ 2 datum คือ WGS84 และ Indian 1975 เท่านั้นโดยแยกย่อยเป็น WGS84 (geographic), Indian 1975 (geographic), WGS84/UTM Zone 47N, WGS84/UTM Zone 48N, Indian 1975/UTM Zone 47N และ Indian 1975/UTM Zone 48N
ฟอร์มของโปรแกรม
รู้สึกว่า post ในตอนนี้จะยาวมากไป ติดตามต่อตอนที่ 2
Related
Hello, I found it a good article.
The links are not available, do you have the code in a repository like github?
Hi, This is very old post. I think we cannot find it anymore.
I understand your comment.
I appreciate the answer.
It was to see an example of using gdal / ogr from pascal. I am trying to incorporate these functions into a program and I cannot find a clear example.
Greetings and thanks.