UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Reserved Words
    • Data Types
    • Alias
    • Operators
    • Expression
    • Filter
    • Prefix
    • Node and Edge Templates
    • Homologous and Heterologous Data
    • Clause Execution Times
    • Graphset
    • Schema
    • Property
    • Insert
    • Overwrite
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • Find Subgraphs
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • BATCH
      • Schema Checker
      • Equal
      • Not Equal
      • Less Than
      • Greater Than
      • Less Than or Equal
      • Greater Than or Equal
      • Between
      • Between or Equal
      • Beong to
      • Not Belong To
      • CONTAINS | String
      • CONTAINS | Full-Text
      • Regular Match
      • IS NULL
      • IS NOT NULL
      • And
      • Or
      • Not
      • Exclusive OR
      • DISTINCT
      • toString()
      • toInteger()
      • toFloat()
      • toDouble()
      • toDecimal()
      • toSet()
      • castToRaw()
      • now()
      • dateAdd()
      • dateDiff()
      • year()
      • month()
      • day()
      • dayOfWeek()
      • dateFormat()
      • point()
      • distance()
      • pointInPolygon()
      • lower()
      • upper()
      • reverse()
      • startsWith()
      • endsWith()
      • JSON_decode()
      • JSON_merge()
      • trim()
      • ltrim()
      • rtrim()
      • left()
      • right()
      • substring()
      • replace()
      • split()
      • intersection()
      • difference()
      • listUnion()
      • size()
      • head()
      • reduce()
      • listContains()
      • append()
      • pi()
      • pow()
      • sqrt()
      • abs()
      • floor()
      • ceil()
      • round()
      • sin()
      • cos()
      • tan()
      • cot()
      • asin()
      • acos()
      • atan()
      • length()
      • pnodes()
      • pedges()
      • count()
      • sum()
      • max()
      • min()
      • avg()
      • stddev()
      • collect()
      • dedup()
      • CASE
      • table()
      • coalesce()
      • ifnull()
    • Acceleration
    • Index
    • Full-text
    • LTE
    • Real-time Process
    • Backend Task
    • Analytics Node
    • Server Statistics
    • Server Backup
    • Privilege
    • Policy
    • User
  • Trigger
  1. Docs
  2. /
  3. UQL
  4. /
  5. Spatial Functions

pointInPolygon()

Function pointInPolygon() judges whether a 2D coordinate locates in (not outside or on ) the boundary of a polygon, and returns 1 for true, 0 for false.

Arguments:

  • 2D coordinates <point|list>
  • Polygon <list>

Returns:

  • Result <number>

Common Usage

Exalmple: Direct calculate

UQL
uncollect [[1.5,0.5],[2,2]] as point
uncollect [[[1,0],[3,0],[3,1],[1,1]],[[1,0],[2,1],[1,2],[0,1]]] as polygon
return table(toString(point), toString(polygon), pointInPolygon(point, polygon))
Result
| toString(point) |     toString(polygon)     | pointInPolygon(point, polygon) |
|-----------------|---------------------------|--------------------------------|
| [1.5,0.5]       | [[1,0],[3,0],[3,1],[1,1]] | 1                              |
| [2,2]           | [[1,0],[2,1],[1,2],[0,1]] | 0                              |

Exalmple: Multiply and calculate

UQL
uncollect [[1.5,0.5],[2,2]] as point
uncollect [[[1,0],[3,0],[3,1],[1,1]],[[1,0],[2,1],[1,2],[0,1]]] as polygon
with pointInPolygon(point, polygon) as result
return table(toString(point), toString(polygon), result)
Result
| toString(point) |     toString(polygon)     | result |
|-----------------|---------------------------|--------|
| [1.5,0.5]       | [[1,0],[3,0],[3,1],[1,1]] | 1      |
| [1.5,0.5]       | [[1,0],[2,1],[1,2],[0,1]] | 0      |
| [2,2]           | [[1,0],[3,0],[3,1],[1,1]] | 0      |
| [2,2]           | [[1,0],[2,1],[1,2],[0,1]] | 0      |