Bug #96711 error with st_within
Submitted: 30 Aug 2019 20:38 Modified: 2 Sep 2019 12:29
Reporter: Ronaldo Freitas Ronaldo Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version: libmysql - mysqlnd 5.0.12-dev - 2015040 OS:Ubuntu (5.7.27-0ubuntu0.16.04.1 - (Ubuntu))
Assigned to: CPU Architecture:Any (VM from DigitalOcean)

[30 Aug 2019 20:38] Ronaldo Freitas Ronaldo
Description:
i Triyng to know if a lat long point its inside an poligon area. I'm using ST_Within. but in an point i donte get correct response. i'm plotted area and point in a map and this poin its inside a map. but "ST_Within" returns 0.

How to repeat:
my original query is this:

SELECT longitude lng, latitude lat, (SELECT JSON_EXTRACT(GeoJson,'$[0]') from c0021.regiaoentrega where idregiaoentrega = 11) C_geojson, ST_Within(GeomFromText(CONCAT('POINT (', `longitude`, ' ', `latitude`, ')'),4326),(SELECT ST_GeomFromGeoJSON(JSON_EXTRACT(GeoJson,'$[0]')) from c0021.regiaoentrega where idregiaoentrega = 11))  ST_Within_ll_GJ from adr.enderecos where cep = '04671072';

i coppied returned data tho help resulting this. With this you can reproduce problem exactly with same data.

set @lng = -46.76648;
set @lat = -23.65065;
set @GJs = '{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[-46.694211959838874, -23.637919505255393], [-46.711206436157234, -23.628169110847946], [-46.72313690185547, -23.64027836255608], [-46.72545433044434, -23.6443669478441], [-46.72528266906739, -23.647197432065852], [-46.72245025634766, -23.651757527860635], [-46.70931816101075, -23.665515474199104], [-46.69275283813477, -23.68532437353648], [-46.68519973754883, -23.695542075835473], [-46.6501808166504, -23.67023215115052], [-46.66906356811524, -23.658833223888845], [-46.68511390686036, -23.65152166473462], [-46.695413589477546, -23.640435618198072], [-46.694211959838874, -23.637919505255393]]]}, "properties": {}}';

SELECT @lng lng, @lat lat, ST_Within(GeomFromText(CONCAT('POINT (', @lng, ' ', @lat, ')'),4326),ST_GeomFromGeoJSON(@GJs))  ST_Within_ll_GJ;
[2 Sep 2019 12:29] MySQL Verification Team
Hi Mr. Ronaldo,

Thank you for your bug report.

However, I do not think that this is a bug ...

First of all, you are using a deprecated function.

GeomFromText() and GeometryFromText() are deprecated as of MySQL 5.7.6 and will be removed in a future MySQL release. Use ST_GeomFromText() and ST_GeometryFromText() instead.

Second, you are not using it correctly and according to our Reference Manual.

Not a bug.