Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Licence copyright format change #1773

Closed
wants to merge 15 commits into from
84 changes: 66 additions & 18 deletions lib/PlaceLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Nominatim;

require_once(CONST_BasePath.'/lib/AddressDetails.php');
require_once(CONST_BasePath.'/lib/Result.php');
require_once CONST_BasePath.'/lib/AddressDetails.php';
require_once CONST_BasePath.'/lib/Result.php';

class PlaceLookup
{
Expand All @@ -26,6 +26,9 @@ class PlaceLookup
protected $sAllowedTypesSQLList = null;
protected $bDeDupe = true;

protected $aLicence = 'Data © OpenStreetMap contributors, ODbL 1.0.';
protected $aCopyright = 'https://osm.org/copyright';


public function __construct(&$oDB)
{
Expand Down Expand Up @@ -89,9 +92,15 @@ public function getMoreUrlParams()
{
$aParams = array();

if ($this->bAddressDetails) $aParams['addressdetails'] = '1';
if ($this->bExtraTags) $aParams['extratags'] = '1';
if ($this->bNameDetails) $aParams['namedetails'] = '1';
if ($this->bAddressDetails) {
$aParams['addressdetails'] = '1';
}
if ($this->bExtraTags) {
$aParams['extratags'] = '1';
}
if ($this->bNameDetails) {
$aParams['namedetails'] = '1';
}

if ($this->bIncludePolygonAsText) $aParams['polygon_text'] = '1';
if ($this->bIncludePolygonAsGeoJSON) $aParams['polygon_geojson'] = '1';
Expand All @@ -102,7 +111,9 @@ public function getMoreUrlParams()
$aParams['polygon_threshold'] = $this->fPolygonSimplificationThreshold;
}

if (!$this->bDeDupe) $aParams['dedupe'] = '0';
if (!$this->bDeDupe) {
$aParams['dedupe'] = '0';
}

return $aParams;
}
Expand Down Expand Up @@ -147,8 +158,9 @@ private function addressImportanceSql($sGeometry, $sPlaceId)

private function langAddressSql($sHousenumber)
{
if ($this->bAddressDetails)
if ($this->bAddressDetails) {
return ''; // langaddress will be computed from address details
}

return 'get_address_by_language(place_id,'.$sHousenumber.','.$this->aLangPrefOrderSql.') AS langaddress,';
}
Expand Down Expand Up @@ -234,10 +246,15 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
$sSQL .= ' housenumber,';
$sSQL .= ' country_code, ';
$sSQL .= ' importance, ';
if (!$this->bDeDupe) $sSQL .= 'place_id,';
if (!$this->bAddressDetails) $sSQL .= 'langaddress, ';
if (!$this->bDeDupe) {
$sSQL .= 'place_id,';
}
if (!$this->bAddressDetails) {
$sSQL .= 'langaddress, ';
}
$sSQL .= ' placename, ';
$sSQL .= ' ref, ';

if ($this->bExtraTags) $sSQL .= 'extratags, ';
if ($this->bNameDetails) $sSQL .= 'name, ';
$sSQL .= ' extra_place ';
Expand All @@ -260,8 +277,12 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
$sSQL .= $this->langAddressSql('-1');
$sSQL .= ' postcode as placename,';
$sSQL .= ' postcode as ref,';
if ($this->bExtraTags) $sSQL .= 'null::text AS extra,';
if ($this->bNameDetails) $sSQL .= 'null::text AS names,';
if ($this->bExtraTags) {
$sSQL .= 'null::text AS extra,';
}
if ($this->bNameDetails) {
$sSQL .= 'null::text AS names,';
}
$sSQL .= ' ST_x(geometry) AS lon, ST_y(geometry) AS lat,';
$sSQL .= ' (0.75-(rank_search::float/40)) AS importance, ';
$sSQL .= $this->addressImportanceSql('geometry', 'lp.parent_place_id');
Expand Down Expand Up @@ -298,8 +319,12 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
$sSQL .= $this->langAddressSql('housenumber_for_place');
$sSQL .= ' null::text AS placename, ';
$sSQL .= ' null::text AS ref, ';
if ($this->bExtraTags) $sSQL .= 'null::text AS extra,';
if ($this->bNameDetails) $sSQL .= 'null::text AS names,';
if ($this->bExtraTags) {
$sSQL .= 'null::text AS extra,';
}
if ($this->bNameDetails) {
$sSQL .= 'null::text AS names,';
}
$sSQL .= ' st_x(centroid) AS lon, ';
$sSQL .= ' st_y(centroid) AS lat,';
$sSQL .= ' -1.15 AS importance, ';
Expand Down Expand Up @@ -344,8 +369,12 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
$sSQL .= $this->langAddressSql('housenumber_for_place');
$sSQL .= ' null::text AS placename, ';
$sSQL .= ' null::text AS ref, ';
if ($this->bExtraTags) $sSQL .= 'null::text AS extra, ';
if ($this->bNameDetails) $sSQL .= 'null::text AS names, ';
if ($this->bExtraTags) {
$sSQL .= 'null::text AS extra, ';
}
if ($this->bNameDetails) {
$sSQL .= 'null::text AS names, ';
}
$sSQL .= ' st_x(centroid) AS lon, ';
$sSQL .= ' st_y(centroid) AS lat, ';
// slightly smaller than the importance for normal houses
Expand Down Expand Up @@ -393,8 +422,12 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
$sSQL .= $this->langAddressSql('-1');
$sSQL .= ' null::text AS placename, ';
$sSQL .= ' null::text AS ref, ';
if ($this->bExtraTags) $sSQL .= 'null::text AS extra, ';
if ($this->bNameDetails) $sSQL .= 'null::text AS names, ';
if ($this->bExtraTags) {
$sSQL .= 'null::text AS extra, ';
}
if ($this->bNameDetails) {
$sSQL .= 'null::text AS names, ';
}
$sSQL .= ' ST_X(centroid) AS lon, ';
$sSQL .= ' ST_Y(centroid) AS lat, ';
$sSQL .= ' -1.10 AS importance, ';
Expand All @@ -421,6 +454,7 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)

foreach ($aPlaces as &$aPlace) {
$aPlace['importance'] = (float) $aPlace['importance'];

if ($this->bAddressDetails) {
// to get addressdetails for tiger data, the housenumber is needed
$aPlace['address'] = new AddressDetails(
Expand All @@ -432,9 +466,19 @@ public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
$aPlace['langaddress'] = $aPlace['address']->getLocaleAddress();
}

$aPlace['licence'] = ($this->aLicence);
$aPlace['copyright'] = ($this->aCopyright);

if ($this->bExtraTags) {
if ($aPlace['extra']) {
$aPlace['sExtraTags'] = json_decode($aPlace['extra']);

if ($aPlace['sExtraTags']->licence) {
$aPlace['licence'] = $aPlace['sExtraTags']->data_licence;
}
if ($aPlace['sExtraTags']->copyright) {
$aPlace['copyright'] = $aPlace['sExtraTags']->data_copyright;
}
} else {
$aPlace['sExtraTags'] = (object) array();
}
Expand Down Expand Up @@ -476,7 +520,9 @@ public function getOutlines($iPlaceID, $fLon = null, $fLat = null, $fRadius = nu
{

$aOutlineResult = array();
if (!$iPlaceID) return $aOutlineResult;
if (!$iPlaceID) {
return $aOutlineResult;
}

if (CONST_Search_AreaPolygons) {
// Get the bounding box and outline polygon
Expand All @@ -489,10 +535,12 @@ public function getOutlines($iPlaceID, $fLon = null, $fLat = null, $fRadius = nu
}
$sSQL .= ' ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,';
$sSQL .= ' ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon';

if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
if ($this->bIncludePolygonAsText) $sSQL .= ',ST_AsText(geometry) as astext';

if ($fLonReverse != null && $fLatReverse != null) {
$sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
$sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
Expand Down
35 changes: 23 additions & 12 deletions lib/template/address-geocodejson.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
$aFilteredPlaces = array();

if (empty($aPlace)) {
if (isset($sError))
if (isset($sError)) {
$aFilteredPlaces['error'] = $sError;
else $aFilteredPlaces['error'] = 'Unable to geocode';
} else {
$aFilteredPlaces['error'] = 'Unable to geocode';
}
javascript_renderData($aFilteredPlaces);
} else {
$aFilteredPlaces = array(
Expand All @@ -17,7 +19,14 @@
)
);

if (isset($aPlace['place_id'])) $aFilteredPlaces['properties']['geocoding']['place_id'] = $aPlace['place_id'];
if (isset($aPlace['place_id'])) {
$aFilteredPlaces['properties']['geocoding']['place_id'] = $aPlace['place_id'];
}

$aFilteredPlaces['properties']['geocoding']['licence'] = $aPlace['licence'];

$aFilteredPlaces['properties']['geocoding']['copyright'] = $aPlace['copyright'];

$sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) {
$aFilteredPlaces['properties']['geocoding']['osm_type'] = $sOSMType;
Expand Down Expand Up @@ -55,14 +64,16 @@
);
}

javascript_renderData(array(
'type' => 'FeatureCollection',
'geocoding' => array(
'version' => '0.1.0',
'attribution' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
'licence' => 'ODbL',
'query' => $sQuery
javascript_renderData(
array(
'type' => 'FeatureCollection',
'geocoding' => array(
'version' => '0.1.0',
// 'attribution' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
// 'licence' => 'ODbL',
'query' => $sQuery
),
'features' => array($aFilteredPlaces)
));
'features' => array($aFilteredPlaces)
)
);
}
35 changes: 25 additions & 10 deletions lib/template/address-geojson.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
$aFilteredPlaces = array();

if (empty($aPlace)) {
if (isset($sError))
if (isset($sError)) {
$aFilteredPlaces['error'] = $sError;
else $aFilteredPlaces['error'] = 'Unable to geocode';
} else {
$aFilteredPlaces['error'] = 'Unable to geocode';
}
javascript_renderData($aFilteredPlaces);
} else {
$aFilteredPlaces = array(
'type' => 'Feature',
'properties' => array()
);

if (isset($aPlace['place_id'])) $aFilteredPlaces['properties']['place_id'] = $aPlace['place_id'];
if (isset($aPlace['place_id'])) {
$aFilteredPlaces['properties']['place_id'] = $aPlace['place_id'];
}

$aFilteredPlaces['properties']['licence'] = $aPlace['licence'];

$aFilteredPlaces['properties']['copyright'] = $aPlace['copyright'];

$sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) {
$aFilteredPlaces['properties']['osm_type'] = $sOSMType;
Expand All @@ -36,8 +45,12 @@
if (isset($aPlace['address'])) {
$aFilteredPlaces['properties']['address'] = $aPlace['address']->getAddressNames();
}
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['properties']['extratags'] = $aPlace['sExtraTags'];
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['properties']['namedetails'] = $aPlace['sNameDetails'];
if (isset($aPlace['sExtraTags'])) {
$aFilteredPlaces['properties']['extratags'] = $aPlace['sExtraTags'];
}
if (isset($aPlace['sNameDetails'])) {
$aFilteredPlaces['properties']['namedetails'] = $aPlace['sNameDetails'];
}

if (isset($aPlace['aBoundingBox'])) {
$aFilteredPlaces['bbox'] = array(
Expand All @@ -61,9 +74,11 @@
}


javascript_renderData(array(
'type' => 'FeatureCollection',
'licence' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
'features' => array($aFilteredPlaces)
));
javascript_renderData(
array(
'type' => 'FeatureCollection',
// 'licence' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
'features' => array($aFilteredPlaces)
)
);
}
31 changes: 23 additions & 8 deletions lib/template/address-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@
$aFilteredPlaces = array();

if (empty($aPlace)) {
if (isset($sError))
if (isset($sError)) {
$aFilteredPlaces['error'] = $sError;
else $aFilteredPlaces['error'] = 'Unable to geocode';
} else {
$aFilteredPlaces['error'] = 'Unable to geocode';
}
} else {
if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
if (isset($aPlace['place_id'])) {
$aFilteredPlaces['place_id'] = $aPlace['place_id'];
}
// $aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$aFilteredPlaces['licence'] = $aPlace['licence'];
$aFilteredPlaces['copyright'] = $aPlace['copyright'];

$sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) {
$aFilteredPlaces['osm_type'] = $sOSMType;
$aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
}
if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];
if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];
if (isset($aPlace['lat'])) {
$aFilteredPlaces['lat'] = $aPlace['lat'];
}
if (isset($aPlace['lon'])) {
$aFilteredPlaces['lon'] = $aPlace['lon'];
}

if ($sOutputFormat == 'jsonv2' || $sOutputFormat == 'geojson') {
$aFilteredPlaces['place_rank'] = $aPlace['rank_search'];
Expand All @@ -35,8 +46,12 @@
if (isset($aPlace['address'])) {
$aFilteredPlaces['address'] = $aPlace['address']->getAddressNames();
}
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
if (isset($aPlace['sExtraTags'])) {
$aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
}
if (isset($aPlace['sNameDetails'])) {
$aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
}

if (isset($aPlace['aBoundingBox'])) {
$aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
Expand Down
Loading