Skip to content
Permalink
Browse files

replace deprecated MYSQL WITHIN function by MBRWITHIN

  • Loading branch information...
following5 committed Dec 23, 2015
1 parent d41888a commit f2e95e46b54a0596e484d8448e25d223526e8a5f
@@ -28,7 +28,7 @@ function run()
{
$sCode = '';
$rsLayers = sql("SELECT `level`, `code`, AsText(`shape`) AS `geometry` FROM `nuts_layer` WHERE WITHIN(GeomFromText('&1'), `shape`) ORDER BY `level` DESC", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
$rsLayers = sql("SELECT `level`, `code`, AsText(`shape`) AS `geometry` FROM `nuts_layer` WHERE MBRWITHIN(GeomFromText('&1'), `shape`) ORDER BY `level` DESC", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
while ($rLayers = sql_fetch_assoc($rsLayers))
{
if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')'))
@@ -26,15 +26,15 @@ function run()
{
sql("DELETE FROM `cache_npa_areas` WHERE `cache_id`='&1' AND `calculated`=1", $rCache['cache_id']);
$rsLayers = sql("SELECT `id`, `type_id`, AsText(`shape`) AS `geometry` FROM `npa_areas` WHERE `exclude`=0 AND WITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
$rsLayers = sql("SELECT `id`, `type_id`, AsText(`shape`) AS `geometry` FROM `npa_areas` WHERE `exclude`=0 AND MBRWITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
while ($rLayers = sql_fetch_assoc($rsLayers))
{
if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')'))
{
$bExclude = false;
// prüfen, ob in ausgesparter Fläche
$rsExclude = sql("SELECT `id`, AsText(`shape`) AS `geometry` FROM `npa_areas` WHERE `exclude`=1 AND `type_id`='&1' AND WITHIN(GeomFromText('&2'), `shape`)", $rLayers['type_id'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
$rsExclude = sql("SELECT `id`, AsText(`shape`) AS `geometry` FROM `npa_areas` WHERE `exclude`=1 AND `type_id`='&1' AND MBRWITHIN(GeomFromText('&2'), `shape`)", $rLayers['type_id'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
while (($rExclude = sql_fetch_assoc($rsExclude)) && ($bExclude==false))
{
if (gis::ptInLineRing($rExclude['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')'))

0 comments on commit f2e95e4

Please sign in to comment.
You can’t perform that action at this time.