Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

const.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """
  2. PostGIS to GDAL conversion constant definitions
  3. """
  4. # Lookup to convert pixel type values from GDAL to PostGIS
  5. GDAL_TO_POSTGIS = [None, 4, 6, 5, 8, 7, 10, 11, None, None, None, None]
  6. # Lookup to convert pixel type values from PostGIS to GDAL
  7. POSTGIS_TO_GDAL = [1, 1, 1, 3, 1, 3, 2, 5, 4, None, 6, 7, None, None]
  8. # Struct pack structure for raster header, the raster header has the
  9. # following structure:
  10. #
  11. # Endianness, PostGIS raster version, number of bands, scale, origin,
  12. # skew, srid, width, and height.
  13. #
  14. # Scale, origin, and skew have x and y values. PostGIS currently uses
  15. # a fixed endianness (1) and there is only one version (0).
  16. POSTGIS_HEADER_STRUCTURE = 'B H H d d d d d d i H H'
  17. # Lookup values to convert GDAL pixel types to struct characters. This is
  18. # used to pack and unpack the pixel values of PostGIS raster bands.
  19. GDAL_TO_STRUCT = [
  20. None, 'B', 'H', 'h', 'L', 'l', 'f', 'd',
  21. None, None, None, None,
  22. ]
  23. # Size of the packed value in bytes for different numerical types.
  24. # This is needed to cut chunks of band data out of PostGIS raster strings
  25. # when decomposing them into GDALRasters.
  26. # See https://docs.python.org/library/struct.html#format-characters
  27. STRUCT_SIZE = {
  28. 'b': 1, # Signed char
  29. 'B': 1, # Unsigned char
  30. '?': 1, # _Bool
  31. 'h': 2, # Short
  32. 'H': 2, # Unsigned short
  33. 'i': 4, # Integer
  34. 'I': 4, # Unsigned Integer
  35. 'l': 4, # Long
  36. 'L': 4, # Unsigned Long
  37. 'f': 4, # Float
  38. 'd': 8, # Double
  39. }