__init__.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright (c) "Neo4j"
  2. # Neo4j Sweden AB [https://neo4j.com]
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # https://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """Spatial data types for interchange with the DBMS."""
  16. from __future__ import annotations
  17. __all__ = [
  18. "CartesianPoint",
  19. "Point",
  20. "WGS84Point",
  21. "dehydrate_point",
  22. "hydrate_point",
  23. "point_type",
  24. ]
  25. import typing as t
  26. from functools import wraps
  27. from .._codec.hydration.v1 import spatial as _hydration
  28. if t.TYPE_CHECKING:
  29. from typing_extensions import deprecated
  30. else:
  31. from .._meta import deprecated
  32. from .._spatial import (
  33. CartesianPoint,
  34. Point,
  35. point_type as _point_type,
  36. WGS84Point,
  37. )
  38. # TODO: 6.0 - remove
  39. @deprecated(
  40. "hydrate_point is considered an internal function and will be removed in "
  41. "a future version"
  42. )
  43. def hydrate_point(srid, *coordinates):
  44. """
  45. Create a new instance of a Point subclass from a raw set of fields.
  46. The subclass chosen is determined by the
  47. given SRID; a ValueError will be raised if no such
  48. subclass can be found.
  49. """
  50. return _hydration.hydrate_point(srid, *coordinates)
  51. # TODO: 6.0 - remove
  52. @deprecated(
  53. "hydrate_point is considered an internal function and will be removed in "
  54. "a future version"
  55. )
  56. @wraps(_hydration.dehydrate_point)
  57. def dehydrate_point(value):
  58. """
  59. Dehydrator for Point data.
  60. :param value:
  61. :type value: Point
  62. :returns:
  63. """
  64. return _hydration.dehydrate_point(value)
  65. # TODO: 6.0 - remove
  66. @deprecated(
  67. "point_type is considered an internal function and will be removed in "
  68. "a future version"
  69. )
  70. @wraps(_point_type)
  71. def point_type(name, fields, srid_map):
  72. return _point_type(name, fields, srid_map)