| 1 |
""" |
| 2 |
This module houses the ctypes function prototypes for OGR DataSource |
| 3 |
related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*, |
| 4 |
OGR_Fld_* routines are relevant here. |
| 5 |
""" |
| 6 |
|
| 7 |
from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_uint, c_void_p |
| 8 |
|
| 9 |
from django.contrib.gis.gdal.envelope import OGREnvelope |
| 10 |
from django.contrib.gis.gdal.libgdal import lgdal |
| 11 |
from django.contrib.gis.gdal.prototypes.generation import ( |
| 12 |
bool_output, |
| 13 |
const_string_output, |
| 14 |
double_output, |
| 15 |
geom_output, |
| 16 |
int64_output, |
| 17 |
int_output, |
| 18 |
srs_output, |
| 19 |
void_output, |
| 20 |
voidptr_output, |
| 21 |
) |
| 22 |
|
| 23 |
c_int_p = POINTER(c_int) # shortcut type |
| 24 |
|
| 25 |
GDAL_OF_READONLY = 0x00 |
| 26 |
GDAL_OF_UPDATE = 0x01 |
| 27 |
|
| 28 |
GDAL_OF_ALL = 0x00 |
| 29 |
GDAL_OF_RASTER = 0x02 |
| 30 |
GDAL_OF_VECTOR = 0x04 |
| 31 |
|
| 32 |
# Driver Routines |
| 33 |
register_all = void_output(lgdal.GDALAllRegister, [], errcheck=False) |
| 34 |
cleanup_all = void_output(lgdal.GDALDestroyDriverManager, [], errcheck=False) |
| 35 |
get_driver = voidptr_output(lgdal.GDALGetDriver, [c_int]) |
| 36 |
get_driver_by_name = voidptr_output( |
| 37 |
lgdal.GDALGetDriverByName, [c_char_p], errcheck=False |
| 38 |
) |
| 39 |
get_driver_count = int_output(lgdal.GDALGetDriverCount, []) |
| 40 |
get_driver_description = const_string_output(lgdal.GDALGetDescription, [c_void_p]) |
| 41 |
|
| 42 |
# DataSource |
| 43 |
open_ds = voidptr_output( |
| 44 |
lgdal.GDALOpenEx, |
| 45 |
[c_char_p, c_uint, POINTER(c_char_p), POINTER(c_char_p), POINTER(c_char_p)], |
| 46 |
) |
| 47 |
destroy_ds = void_output(lgdal.GDALClose, [c_void_p], errcheck=False) |
| 48 |
get_ds_name = const_string_output(lgdal.GDALGetDescription, [c_void_p]) |
| 49 |
get_dataset_driver = voidptr_output(lgdal.GDALGetDatasetDriver, [c_void_p]) |
| 50 |
get_layer = voidptr_output(lgdal.GDALDatasetGetLayer, [c_void_p, c_int]) |
| 51 |
get_layer_by_name = voidptr_output( |
| 52 |
lgdal.GDALDatasetGetLayerByName, [c_void_p, c_char_p] |
| 53 |
) |
| 54 |
get_layer_count = int_output(lgdal.GDALDatasetGetLayerCount, [c_void_p]) |
| 55 |
|
| 56 |
# Layer Routines |
| 57 |
get_extent = void_output(lgdal.OGR_L_GetExtent, [c_void_p, POINTER(OGREnvelope), c_int]) |
| 58 |
get_feature = voidptr_output(lgdal.OGR_L_GetFeature, [c_void_p, c_long]) |
| 59 |
get_feature_count = int_output(lgdal.OGR_L_GetFeatureCount, [c_void_p, c_int]) |
| 60 |
get_layer_defn = voidptr_output(lgdal.OGR_L_GetLayerDefn, [c_void_p]) |
| 61 |
get_layer_srs = srs_output(lgdal.OGR_L_GetSpatialRef, [c_void_p]) |
| 62 |
get_next_feature = voidptr_output(lgdal.OGR_L_GetNextFeature, [c_void_p]) |
| 63 |
reset_reading = void_output(lgdal.OGR_L_ResetReading, [c_void_p], errcheck=False) |
| 64 |
test_capability = int_output(lgdal.OGR_L_TestCapability, [c_void_p, c_char_p]) |
| 65 |
get_spatial_filter = geom_output(lgdal.OGR_L_GetSpatialFilter, [c_void_p]) |
| 66 |
set_spatial_filter = void_output( |
| 67 |
lgdal.OGR_L_SetSpatialFilter, [c_void_p, c_void_p], errcheck=False |
| 68 |
) |
| 69 |
set_spatial_filter_rect = void_output( |
| 70 |
lgdal.OGR_L_SetSpatialFilterRect, |
| 71 |
[c_void_p, c_double, c_double, c_double, c_double], |
| 72 |
errcheck=False, |
| 73 |
) |
| 74 |
|
| 75 |
# Feature Definition Routines |
| 76 |
get_fd_geom_type = int_output(lgdal.OGR_FD_GetGeomType, [c_void_p]) |
| 77 |
get_fd_name = const_string_output(lgdal.OGR_FD_GetName, [c_void_p]) |
| 78 |
get_feat_name = const_string_output(lgdal.OGR_FD_GetName, [c_void_p]) |
| 79 |
get_field_count = int_output(lgdal.OGR_FD_GetFieldCount, [c_void_p]) |
| 80 |
get_field_defn = voidptr_output(lgdal.OGR_FD_GetFieldDefn, [c_void_p, c_int]) |
| 81 |
|
| 82 |
# Feature Routines |
| 83 |
clone_feature = voidptr_output(lgdal.OGR_F_Clone, [c_void_p]) |
| 84 |
destroy_feature = void_output(lgdal.OGR_F_Destroy, [c_void_p], errcheck=False) |
| 85 |
feature_equal = int_output(lgdal.OGR_F_Equal, [c_void_p, c_void_p]) |
| 86 |
get_feat_geom_ref = geom_output(lgdal.OGR_F_GetGeometryRef, [c_void_p]) |
| 87 |
get_feat_field_count = int_output(lgdal.OGR_F_GetFieldCount, [c_void_p]) |
| 88 |
get_feat_field_defn = voidptr_output(lgdal.OGR_F_GetFieldDefnRef, [c_void_p, c_int]) |
| 89 |
get_fid = int_output(lgdal.OGR_F_GetFID, [c_void_p]) |
| 90 |
get_field_as_datetime = int_output( |
| 91 |
lgdal.OGR_F_GetFieldAsDateTime, |
| 92 |
[c_void_p, c_int, c_int_p, c_int_p, c_int_p, c_int_p, c_int_p, c_int_p], |
| 93 |
) |
| 94 |
get_field_as_double = double_output(lgdal.OGR_F_GetFieldAsDouble, [c_void_p, c_int]) |
| 95 |
get_field_as_integer = int_output(lgdal.OGR_F_GetFieldAsInteger, [c_void_p, c_int]) |
| 96 |
get_field_as_integer64 = int64_output( |
| 97 |
lgdal.OGR_F_GetFieldAsInteger64, [c_void_p, c_int] |
| 98 |
) |
| 99 |
is_field_set = bool_output(lgdal.OGR_F_IsFieldSetAndNotNull, [c_void_p, c_int]) |
| 100 |
get_field_as_string = const_string_output( |
| 101 |
lgdal.OGR_F_GetFieldAsString, [c_void_p, c_int] |
| 102 |
) |
| 103 |
get_field_index = int_output(lgdal.OGR_F_GetFieldIndex, [c_void_p, c_char_p]) |
| 104 |
|
| 105 |
# Field Routines |
| 106 |
get_field_name = const_string_output(lgdal.OGR_Fld_GetNameRef, [c_void_p]) |
| 107 |
get_field_precision = int_output(lgdal.OGR_Fld_GetPrecision, [c_void_p]) |
| 108 |
get_field_type = int_output(lgdal.OGR_Fld_GetType, [c_void_p]) |
| 109 |
get_field_type_name = const_string_output(lgdal.OGR_GetFieldTypeName, [c_int]) |
| 110 |
get_field_width = int_output(lgdal.OGR_Fld_GetWidth, [c_void_p]) |