Merge branch 'feature/polygon-simplification' of https://github.com/a1exsh/Nominatim

This commit is contained in:
Sarah Hoffmann 2015-04-30 21:26:11 +02:00
commit a7e1b3b1ee
2 changed files with 21 additions and 1 deletions

View File

@ -12,6 +12,7 @@
protected $bIncludePolygonAsGeoJSON = false;
protected $bIncludePolygonAsKML = false;
protected $bIncludePolygonAsSVG = false;
protected $fPolygonSimplificationThreshold = 0.0;
protected $aExcludePlaceIDs = array();
protected $bDeDupe = true;
@ -102,6 +103,11 @@
$this->bIncludePolygonAsSVG = $b;
}
function setPolygonSimplificationThreshold($f)
{
$this->fPolygonSimplificationThreshold = $f;
}
function setDeDupe($bDeDupe = true)
{
$this->bDeDupe = (bool)$bDeDupe;
@ -1599,7 +1605,16 @@
if ($this->bIncludePolygonAsKML) $sSQL .= ",ST_AsKML(geometry) as askml";
if ($this->bIncludePolygonAsSVG) $sSQL .= ",ST_AsSVG(geometry) as assvg";
if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ",ST_AsText(geometry) as astext";
$sSQL .= " from placex where place_id = ".$aResult['place_id'];
$sFrom = " from placex where place_id = ".$aResult['place_id'];
if ($this->fPolygonSimplificationThreshold > 0)
{
$sSQL .= " from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,".$this->fPolygonSimplificationThreshold.") as geometry".$sFrom.") as plx";
}
else
{
$sSQL .= $sFrom;
}
$aPointPolygon = $this->oDB->getRow($sSQL);
if (PEAR::IsError($aPointPolygon))
{

View File

@ -68,6 +68,11 @@
$oGeocode->setIncludePolygonAsSVG($bAsSVG);
}
// Polygon simplification threshold (optional)
$fThreshold = 0.0;
if (isset($_GET['polygon_threshold'])) $fThreshold = (float)$_GET['polygon_threshold'];
$oGeocode->setPolygonSimplificationThreshold($fThreshold);
$oGeocode->loadParamArray($_GET);
if (CONST_Search_BatchMode && isset($_GET['batch']))