Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 281255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:11:16+00:00 2026-05-12T05:11:16+00:00

This question is for Mysql geospatial-extension experts. The following query doesn’t the result that

  • 0

This question is for Mysql geospatial-extension experts.

The following query doesn’t the result that I’m expecting:

create database test_db;

use test_db;

create table test_table (g polygon not null);

insert into test_table (g) values (geomfromtext('Polygon((0 5,5 10,7 8,2 3,0 5))'));
insert into test_table (g) values (geomfromtext('Polygon((2 3,7  8,9 6,4 1,2 3))'));

select

X(PointN(ExteriorRing(g),1)), Y(PointN(ExteriorRing(g),1)),
X(PointN(ExteriorRing(g),2)), Y(PointN(ExteriorRing(g),2)),
X(PointN(ExteriorRing(g),3)), Y(PointN(ExteriorRing(g),3)),
X(PointN(ExteriorRing(g),4)), Y(PointN(ExteriorRing(g),4))

from test_table where MBRContains(g,GeomFromText('Point(3 6)'));

Basically we are creating 2 Polygons, and we are trying to use MBRContains to determine whether a Point is within either of the two polygons.

Surprisingly, it returns both polygons! Point 3,6 should only exist in the first inserted polygon.

Note that both polygons are tilted (once you draw the polygons on a piece of paper, you will see)

How come MySql returns both polygons? I’m using MySql Community Edition 5.1.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:11:16+00:00Added an answer on May 12, 2026 at 5:11 am

    UPDATE: Hopefully this answer has been obsoleted by MySQL: http://forge.mysql.com/wiki/GIS_Functions! Will leave as reference for older MBRContains implementations but a new answer explaining the changes would be welcome and should be “accepted” above this one.

    begin obsolete answer

    You are using (by necessity) minimum bounding rectangles, not the polygons as such. For the purpose of your query the shape being compared is equivalent to:

    'POLYGON(0 2,0 10,7 10,7 2,0 2)'

    for the first shape and:

    'POLYGON(2 1,9 1,9 9,2 9,2 1)'

    for the second. (3,6) is in both.

    MBR is a rough way of estimation, picture the rectangle as having vertical lines at min(x) and max(x), and horizontal lines at max(y) and min(y). Those shapes are easier for the database to calculate, MySQL does not support all polygon functions. (Area yes, linestrings generally yes, contains not yet. More details here.). If you want more precise geospatial geometry at the moment the best choice on the open source side is PostGIS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 247k
  • Answers 247k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer MVCContrib 1.0.0.987 Stable May 13, 2026 at 8:39 am
  • Editorial Team
    Editorial Team added an answer T_PAAMAYIM_NEKUDOTAYIM is the double colon scope resolution thingy PHP uses… May 13, 2026 at 8:39 am
  • Editorial Team
    Editorial Team added an answer using System; using System.IO; class DirectoryCopyExample { static void Main()… May 13, 2026 at 8:39 am

Related Questions

This question is for Mysql geospatial-extension experts. The following query doesn't the result that
This question is in continuation to my previous post located here . Since there
This is for MySQL and PHP I have a table that contains the following
This question is based on this thread . Problem: to access MySQL's manual when
This is a weird issue. I'm accessing my online database using premiumsofts Navicat for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.