6 Fix typo: MBRContians -> MBRContains
source | link

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant at this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContiansMBRContains(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester.

Click herehere for a list of MySQL's Spatial Functions which you can now use with yourthe new typecolumn. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant at this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant at this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContains(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester.

Click here for a list of MySQL's Spatial Functions which you can now use with the new column. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

    Mod Moved Comments To Chat
5 added 1 character in body
source | link

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant aat this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant a this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant at this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

4 added 169 characters in body
source | link

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant a this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

I have the following function which works to test if the a latitude and longitude is withing a rectangle.

NOOOOO. You're recreating the wheel.

Use geospatial

First we need to add a column, and then we populate it.

ALTER TABLE geom ADD pt POINT;

UPDATE geom
  SET pt = point(longitude, latitude);

ALTER TABLE geom DROP COLUMN latitude, DROP COLUMN longitude;

We dropped the old columns because they're redundant a this point. You can access what was the longitude and latitude by using ST_X(pt), and ST_Y(pt) respectively.

Then we add the index.

ALTER TABLE geom ADD SPATIAL INDEX(g);

Now, we can use an indexable operation with ST_MakeEnvelope

SELECT *
FROM geom
WHERE MBRContians(
  ST_MakeEnvelope(Point(x1,y1),Point(x2,y2)),
  pt
);

See an example of the above working on MySQL 5.7 on RexTester

Click here for a list of MySQL's Spatial Functions which you can now use with your new type. When speaking of GIS, I always suggest MySQL users upgrade to a better database. =)

3 added 106 characters in body
source | link
2 deleted 2 characters in body
source | link
1
source | link