circle.asciidoc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ingest-circle-processor]]
  4. === Circle Processor
  5. Converts circle definitions of shapes to regular polygons which approximate them.
  6. [[circle-processor-options]]
  7. .Circle Processor Options
  8. [options="header"]
  9. |======
  10. | Name | Required | Default | Description
  11. | `field` | yes | - | The string-valued field to trim whitespace from
  12. | `target_field` | no | `field` | The field to assign the polygon shape to, by default `field` is updated in-place
  13. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  14. | `error_distance` | yes | - | The difference between the resulting inscribed distance from center to side and the circle's radius (measured in meters for `geo_shape`, unit-less for `shape`)
  15. | `shape_type` | yes | - | which field mapping type is to be used when processing the circle: `geo_shape` or `shape`
  16. include::common-options.asciidoc[]
  17. |======
  18. image:images/spatial/error_distance.png[]
  19. [source,console]
  20. --------------------------------------------------
  21. PUT circles
  22. {
  23. "mappings": {
  24. "properties": {
  25. "circle": {
  26. "type": "geo_shape"
  27. }
  28. }
  29. }
  30. }
  31. PUT _ingest/pipeline/polygonize_circles
  32. {
  33. "description": "translate circle to polygon",
  34. "processors": [
  35. {
  36. "circle": {
  37. "field": "circle",
  38. "error_distance": 28.0,
  39. "shape_type": "geo_shape"
  40. }
  41. }
  42. ]
  43. }
  44. --------------------------------------------------
  45. Using the above pipeline, we can attempt to index a document into the `circles` index.
  46. The circle can be represented as either a WKT circle or a GeoJSON circle. The resulting
  47. polygon will be represented and indexed using the same format as the input circle. WKT will
  48. be translated to a WKT polygon, and GeoJSON circles will be translated to GeoJSON polygons.
  49. ==== Example: Circle defined in Well Known Text
  50. In this example a circle defined in WKT format is indexed
  51. [source,console]
  52. --------------------------------------------------
  53. PUT circles/_doc/1?pipeline=polygonize_circles
  54. {
  55. "circle": "CIRCLE (30 10 40)"
  56. }
  57. GET circles/_doc/1
  58. --------------------------------------------------
  59. // TEST[continued]
  60. The response from the above index request:
  61. [source,console-result]
  62. --------------------------------------------------
  63. {
  64. "found": true,
  65. "_index": "circles",
  66. "_id": "1",
  67. "_version": 1,
  68. "_seq_no": 22,
  69. "_primary_term": 1,
  70. "_source": {
  71. "circle": "POLYGON ((30.000365257263184 10.0, 30.000111397193788 10.00034284530941, 29.999706043744222 10.000213571721195, 29.999706043744222 9.999786428278805, 30.000111397193788 9.99965715469059, 30.000365257263184 10.0))"
  72. }
  73. }
  74. --------------------------------------------------
  75. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  76. ==== Example: Circle defined in GeoJSON
  77. In this example a circle defined in GeoJSON format is indexed
  78. [source,console]
  79. --------------------------------------------------
  80. PUT circles/_doc/2?pipeline=polygonize_circles
  81. {
  82. "circle": {
  83. "type": "circle",
  84. "radius": "40m",
  85. "coordinates": [30, 10]
  86. }
  87. }
  88. GET circles/_doc/2
  89. --------------------------------------------------
  90. // TEST[continued]
  91. The response from the above index request:
  92. [source,console-result]
  93. --------------------------------------------------
  94. {
  95. "found": true,
  96. "_index": "circles",
  97. "_id": "2",
  98. "_version": 1,
  99. "_seq_no": 22,
  100. "_primary_term": 1,
  101. "_source": {
  102. "circle": {
  103. "coordinates": [
  104. [
  105. [30.000365257263184, 10.0],
  106. [30.000111397193788, 10.00034284530941],
  107. [29.999706043744222, 10.000213571721195],
  108. [29.999706043744222, 9.999786428278805],
  109. [30.000111397193788, 9.99965715469059],
  110. [30.000365257263184, 10.0]
  111. ]
  112. ],
  113. "type": "Polygon"
  114. }
  115. }
  116. }
  117. --------------------------------------------------
  118. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  119. ==== Notes on Accuracy
  120. Accuracy of the polygon that represents the circle is defined as `error_distance`. The smaller this
  121. difference is, the closer to a perfect circle the polygon is.
  122. Below is a table that aims to help capture how the radius of the circle affects the resulting number of sides
  123. of the polygon given different inputs.
  124. The minimum number of sides is `4` and the maximum is `1000`.
  125. [[circle-processor-accuracy]]
  126. .Circle Processor Accuracy
  127. [options="header"]
  128. |======
  129. | error_distance | radius in meters | number of sides of polygon
  130. | 1.00 | 1.0 | 4
  131. | 1.00 | 10.0 | 14
  132. | 1.00 | 100.0 | 45
  133. | 1.00 | 1000.0 | 141
  134. | 1.00 | 10000.0 | 445
  135. | 1.00 | 100000.0 | 1000
  136. |======