]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-error-html.php
factor out link formatting function and osm type translation
[nominatim.git] / lib / template / details-error-html.php
1 <?php
2         header("content-type: text/html; charset=UTF-8");
3 ?>
4 <?php include(CONST_BasePath.'/lib/template/includes/html-header.php'); ?>
5         <link href="css/common.css" rel="stylesheet" type="text/css" />
6         <link href="css/details.css" rel="stylesheet" type="text/css" />
7 </head>
8
9
10 <?php
11
12         function osmMapUrl($aFeature)
13         {
14                 $sLon = $aFeature['error_x'];
15                 $sLat = $aFeature['error_y'];
16
17                 if (isset($sFeature['error_x']) && isset($sFeature['error_y']))
18                 {
19                         $sBaseUrl = '//www.openstreetmap.org/';
20                         $sOSMType = formatOSMType($aFeature['osm_type'], false);
21                         if ($sOSMType)
22                         {
23                                 $sBaseUrl += $sOSMType.'/'.$aFeature['osm_id'];
24                         }
25
26                                 return '<a href="'.$sBaseUrl.'?mlat='.$sLat.'&mlon='.$sLon.'">view on osm.org</a>';
27                         }
28                 }
29                 return '';
30         }
31
32         function josm_edit_url($aFeature)
33         {
34                 $fWidth = 0.0002;
35                 $sLon = $aFeature['error_x'];
36                 $sLat = $aFeature['error_y'];
37
38                 if (isset($sLat))
39                 {
40                         return "http://localhost:8111/load_and_zoom?left=".($sLon-$fWidth)."&right=".($sLon+$fWidth)."&top=".($sLat+$fWidth)."&bottom=".($sLat-$fWidth);
41                 }
42
43                 $sOSMType = formatOSMType($aFeature['osm_type'], false);
44                 if ($sOSMType)
45                 {
46                         return 'http://localhost:8111/import?url=http://www.openstreetmap.org/api/0.6/'.$sOSMType.'/'.$aFeature['osm_id'].'/full';
47                         // Should be better to load by object id - but this doesn't seem to zoom correctly
48                         // return " <a href=\"http://localhost:8111/load_object?new_layer=true&objects=".strtolower($aFeature['osm_type']).$sOSMID."\" target=\"josm\">Remote Control (JOSM / Merkaartor)</a>";
49                 }
50                 return '';
51         }
52
53         function potlach_edit_url($aFeature)
54         {
55                 $fWidth = 0.0002;
56                 $sLat = $aFeature['error_y'];
57                 $sLon = $aFeature['error_x'];
58
59                 if (isset($sLat))
60                 {
61                         return "//www.openstreetmap.org/edit?editor=potlatch2&bbox=".($sLon-$fWidth).",".($sLat-$fWidth).",".($sLon+$fWidth).",".($sLat+$fWidth);
62                 }
63                 return '';
64         }
65
66
67
68 ?>
69
70 <body id="details-page">
71         <div class="container">
72                 <div class="row">
73                         <div class="col-md-6">
74
75
76                                 <h1><?php echo $aPointDetails['localname'] ?></h1>
77                                 <div class="locationdetails">
78                                         <h2 class="bg-danger">This object has an invalid geometry.</h2>
79
80                                         <div>
81                                                 Type: <span class="type"><?php echo $aPointDetails['class'].':'.$aPointDetails['type'];?></span>
82                                         </div>
83
84                                         <div>
85                                                 OSM: <span class="label"><?php echo osmLink($aPointDetails); ?><span>
86                                         </div>
87
88
89                                         <h4>Error</h4>
90                                         <p>
91                                                 <?php echo $aPointDetails['errormessage']?$aPointDetails['errormessage']:'unknown'; ?>
92                                         </p>
93                                         <?php echo osmMapUrl($aPointDetails); ?>
94
95                                         <h4>Edit</h4>
96                                         <ul>
97                                         <?php if (josm_edit_url($aPointDetails)) { ?>
98                                                         <li><a href="<?php echo josm_edit_url($aPointDetails); ?>" target="josm">Remote Control (JOSM / Merkaartor)</a></li>
99                                         <?php } ?>
100                                         <?php if (potlach_edit_url($aPointDetails)) { ?>
101                                                         <li><a href="<?php echo potlach_edit_url($aPointDetails); ?>" target="potlatch2">Potlatch 2</a></li>
102                                         <?php } ?>
103                                         </ul>
104                         </div>
105                 </div>
106                 <div class="col-md-6">
107                         <div id="map"></div>
108                 </div>
109
110         </div>
111
112
113         <script type="text/javascript">
114
115                 var nominatim_result = {
116                         outlinestring: '<?php echo $aPointDetails['outlinestring'];?>',
117                         lon: <?php echo isset($aPointDetails['error_x']) ? $aPointDetails['error_x'] : 0; ?>,
118                         lat: <?php echo isset($aPointDetails['error_y']) ? $aPointDetails['error_y'] : 0; ?>
119                 };
120
121         </script>
122
123
124         <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
125         </body>
126 </html>