Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-36058

ST_CROSSES returns 0 instead of NULL

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.11, 11.4, 11.7(EOL)
    • 10.5, 10.6, 10.11, 11.4
    • GIS
    • None

    Description

      https://mariadb.com/kb/en/st-crosses/ : Returns 1 if geometry g1 spatially crosses geometry g2. Returns NULL if g1 is a Polygon or a MultiPolygon, or if g2 is a Point or a MultiPoint. Otherwise, returns 0.

      MariaDB [test]> SELECT ST_CROSSES( ST_GEOMFROMTEXT('point(1 1)'), st_geomfromtext('point(1 1)') ) a;
      +------+
      | a    |
      +------+
      |    0 |
      +------+
      1 row in set (0,000 sec)
       
      MariaDB [test]> SELECT ST_CROSSES( ST_GEOMFROMTEXT('POLYGON ((59 18,67 18,67 13,59 13,59 18)) '), st_geomfromtext('polygon((2 2,2 4, 4 2,2 2))') ) a;
      +------+
      | a    |
      +------+
      |    0 |
      +------+
      1 row in set (0,001 sec)
       
      MariaDB [test]> SELECT ST_CROSSES( ST_GEOMFROMTEXT('POLYGON ((59 18,67 18,67 13,59 13,59 18)) '), st_geomfromtext('point(1 1)') ) a;
      +------+
      | a    |
      +------+
      |    0 |
      +------+
      1 row in set (0,000 sec)
      
      

      from the KB example:

       
      MariaDB [test]> SET @g1 = ST_GEOMFROMTEXT('LINESTRING(174 149, 176 151)');
      Query OK, 0 rows affected (0,000 sec)
       
      MariaDB [test]> SET @g2 = ST_GEOMFROMTEXT('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))');
      Query OK, 0 rows affected (0,009 sec)
       
      MariaDB [test]> SELECT ST_CROSSES(@g1,@g2);
      +---------------------+
      | ST_CROSSES(@g1,@g2) |
      +---------------------+
      |                   1 |
      +---------------------+
      1 row in set (0,002 sec)
       
      MariaDB [test]> SELECT ST_CROSSES(@g2,@g1);   ## NULL expected
      +---------------------+
      | ST_CROSSES(@g2,@g1) |
      +---------------------+
      |                   1 |
      +---------------------+
      1 row in set (0,001 sec)
      

      mysql> SET @g1 = ST_GEOMFROMTEXT('LINESTRING(174 149, 176 151)');
      Query OK, 0 rows affected (0,01 sec)
       
      mysql> SET @g2 = ST_GEOMFROMTEXT('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))');
      Query OK, 0 rows affected (0,00 sec)
       
      mysql> SELECT ST_CROSSES(@g1,@g2);
      +---------------------+
      | ST_CROSSES(@g1,@g2) |
      +---------------------+
      |                   0 |
      +---------------------+
      1 row in set (0,00 sec)
       
      mysql> SELECT ST_CROSSES(@g2,@g1);
      +---------------------+
      | ST_CROSSES(@g2,@g1) |
      +---------------------+
      |                NULL |
      +---------------------+
      1 row in set (0,00 sec)
      

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

              holyfoot Alexey Botchkov
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.