Changeset 33125


Ignore:
Timestamp:
2019-05-31T20:02:40+12:00 (5 years ago)
Author:
wy59
Message:

First commit to do with adding support for the Coordinate metadata newly introduced. It doesn't yet replace Latitude and Longitude meta, but coexists with that. For docs that only contain lat and lng meta, the code will still behave as before. For docs that contain the new coord meta, the changes in this commit will be able to display markers on the map based on this. Updates include: doc.pm perl code now stores Coordinate and Coordshort meta when it encounters GPS.mapOverlay metadata created by the doc editor. Update to JS code: update to the rawquery search performed to get all docs whose coord info occur within the bounds of the displayed map, and updates to all the js and xsl code that used to only work with lat and lng before now ADDITIONALLY work with coord meta.

Location:
main/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/doc.pm

    r32590 r33125  
    4242##use hashdoc;
    4343use docprint;
     44use JSON;
     45
     46# We just need pi from the Trig lib
     47# Import constants pi2, pip2, pip4 (2*pi, pi/2, pi/4).
     48use Math::Trig ':pi';
    4449
    4550# the document type may be indexed_doc, nonindexed_doc, or
     
    11291134           
    11301135            #Only add the metadata if it has not already been added
    1131             my $metaMap = $self->get_metadata_hashmap($section);
     1136            my $metaMap = $self->get_metadata_hashmap($section); ### TODO: metaMap not used. Unnecesssary step? (Called function has no side-effects.)
    11321137        }
    11331138    }
    11341139
     1140    elsif($field eq "GPS.mapOverlay") { # then the value is a JSON string
     1141        print STDERR "GPS.mapOverlay before val: " . $value . "\n";
     1142       
     1143        # TODO html decode?
     1144        $value =~ s@[@[@g;
     1145        $value =~ s@]@]@g;
     1146        $value =~ s@"@"@g;
     1147        print STDERR "GPS.mapOverlay after val: " . $value . "\n";
     1148
     1149        my $json_array = decode_json $value;
     1150        #my $json = JSON->new->allow_nonref;
     1151        #&printAllShapes($json, $json_array);
     1152
     1153        foreach my $shape (@$json_array) {     
     1154
     1155            my $type = $shape->{"type"};
     1156            print STDERR "Type : " . $type . "\n";
     1157       
     1158            if($type eq "circle") {
     1159                #print STDERR "Found a circle:\n" . &printShape($json, $shape);
     1160       
     1161                # work out bounding box
     1162                # SCARY!
     1163                # want the inverse of this useful page:
     1164                # https://stackoverflow.com/questions/639695/how-to-convert-latitude-or-longitude-to-meters
     1165                # https://www.geodatasource.com/developers/javascript       
     1166               
     1167                           
     1168                # for now, just process the circle centre
     1169                #my $centre = $shape->{"center"};               
     1170                #$self->processLatOrLng($section_ptr, "Latitude", $centre->{"lat"});
     1171                #$self->processLatOrLng($section_ptr, "Longitude", $centre->{"lng"});
     1172
     1173               
     1174                # Dr Bainbridge wants us to use: https://gis.stackexchange.com/questions/5821/calculating-latitude-longitude-x-miles-from-point
     1175                # But we're using the rule of thumb here, since for N,E,S,W it works out the same:
     1176                # https://gis.stackexchange.com/questions/2951/algorithm-for-offsetting-a-latitude-longitude-by-some-amount-of-meters
     1177                # which states
     1178                # "If your displacements aren't too great (less than a few kilometers) and you're not right at the poles,
     1179                # use the quick and dirty estimate that 111,111 meters (111.111 km) in the y direction is 1 degree
     1180                # (of latitude) and 111,111 * cos(latitude) meters in the x direction is 1 degree (of longitude)."
     1181                my $centre_lat = $shape->{"center"}->{"lat"};
     1182                my $centre_lng = $shape->{"center"}->{"lng"};
     1183                my $radius = $shape->{"radius"}; # in metres!
     1184
     1185                print STDERR "@@@ circle centre: ($centre_lat, $centre_lng), radius: $radius\n";
     1186
     1187                my $lat_north = $centre_lat + ($radius/111111);
     1188                my $lat_south = $centre_lat - ($radius/111111);
     1189               
     1190                print STDERR "### lat_north:  $lat_north\n";
     1191                print STDERR "### lat_south:  $lat_south\n";
     1192
     1193                # our latitude and longitude values are in degrees. But cos and sin etc in perl and generally all prog languages
     1194                # all expect their angle to be in radians. So need to convert from degree to radians before we can take the cose of it.
     1195                my $centre_lat_radians = $self->degreesToRadians($centre_lat);
     1196                my $cos_in_radians = cos($centre_lat_radians);             
     1197                print STDERR "cos $centre_lat_radians " . cos($centre_lat_radians) . "\n";
     1198                my $lng_east = $centre_lng + ($radius/(111111 * $cos_in_radians));
     1199                my $lng_west = $centre_lng - ($radius/(111111 * $cos_in_radians));
     1200                print STDERR "### lng_east  $lng_east\n";
     1201                print STDERR "### lng_west  $lng_west\n";
     1202
     1203
     1204
     1205                my $cos_lat = cos($centre_lat);             
     1206                print STDERR "cos $centre_lat is $cos_lat\n";
     1207
     1208                $self->processCoordinate($section_ptr, $lat_north, $lng_east);             
     1209                $self->processCoordinate($section_ptr, $lat_south, $lng_east);
     1210                $self->processCoordinate($section_ptr, $lat_south, $lng_west);
     1211                $self->processCoordinate($section_ptr, $lat_north, $lng_west);
     1212           
     1213            }
     1214            elsif ($type eq "marker") {
     1215                print STDERR "@@ MARKER FOUND WITH LAT: " . $shape->{"position"}->{"lat"} . "\n";
     1216                print STDERR "@@ MARKER FOUND WITH LNG: " . $shape->{"position"}->{"lng"} . "\n";
     1217                $self->processCoordinate($section_ptr, $shape->{"position"}->{"lat"}, $shape->{"position"}->{"lng"});               
     1218            }
     1219            elsif ($type eq "polyline" || $type eq "polygon") {
     1220                my $path_array = $shape->{"path"};
     1221                foreach my $position (@$path_array) {                                   
     1222                    $self->processCoordinate($section_ptr, $position->{"lat"}, $position->{"lng"});
     1223                }
     1224            }
     1225            elsif ($type eq "rectangle") {
     1226       
     1227                my $bounds = $shape->{"bounds"};               
     1228           
     1229                $self->processCoordinate($section_ptr, $bounds->{"north"}, $bounds->{"east"});
     1230                $self->processCoordinate($section_ptr, $bounds->{"south"}, $bounds->{"east"});
     1231                $self->processCoordinate($section_ptr, $bounds->{"south"}, $bounds->{"west"});
     1232                $self->processCoordinate($section_ptr, $bounds->{"north"}, $bounds->{"west"});
     1233            }   
     1234       
     1235        } # end for on each shape in GPS.mapOverlay
     1236
     1237    } # end GPS.mapOverlay meta
     1238
    11351239    push (@{$section_ptr->{'metadata'}}, [$field, $value]);
     1240}
     1241
     1242# https://en.wikipedia.org/wiki/Radian
     1243sub degreesToRadians
     1244{
     1245    my $self = shift (@_);
     1246    my ($degrees) = @_;
     1247
     1248    return $degrees * pi /180; # returns radians
     1249}
     1250
     1251sub radiansToDegrees
     1252{
     1253    my $self = shift (@_);
     1254    my ($radians) = @_;
     1255
     1256    return $radians * 180 / pi; # returns degrees
     1257}
     1258
     1259sub printAllShapes {
     1260    my ($json, $json_array) = @_;
     1261   
     1262   
     1263    #my $pretty_print_shape = $json->pretty->encode( $json_array->[0] );
     1264    foreach my $shape (@$json_array) {
     1265        my $pretty_print_shape = $json->pretty->encode( $shape );
     1266        print STDERR "Shape: $pretty_print_shape\n";
     1267        #&printShape($shape);
     1268    }
     1269   
     1270}   
     1271
     1272sub processCoordinate {
     1273    my $self = shift (@_);
     1274    my ($section_ptr, $latitude, $longitude) = @_;
     1275
     1276    my $lat_direction = ($latitude =~ m/^-/) ? "S" : "N";
     1277    my $lng_direction = ($longitude =~ m/^-/) ? "W" : "E";
     1278   
     1279    # have to store (lat, lng) in pairs, when there are so many coords to store
     1280    #push (@{$section_ptr->{'metadata'}}, ["Latitude", $latitude]);
     1281    #push (@{$section_ptr->{'metadata'}}, ["Longitude", $longitude]);
     1282
     1283    push (@{$section_ptr->{'metadata'}}, ["Coordinate", "$latitude $longitude"]); # "$latitude$lat_direction $longitude$lng_direction"
     1284
     1285    my ($latBeforeDec, $latAfterDec);
     1286    my ($lngBeforeDec, $lngAfterDec);
     1287
     1288    if($latitude !~ m/\./) {
     1289        $latBeforeDec = $latitude;
     1290        $latAfterDec = "";
     1291    } else {
     1292        ($latBeforeDec, $latAfterDec) = ($latitude =~ m/^-?([0-9]+)\.([0-9]+)$/);
     1293    }
     1294    if($longitude !~ m/\./) {
     1295        $lngBeforeDec = $longitude;
     1296        $lngAfterDec = "";
     1297    } else {
     1298        ($lngBeforeDec, $lngAfterDec) = ($longitude =~ m/^-?([0-9]+)\.([0-9]+)$/);
     1299    }   
     1300   
     1301    #if(defined $beforeDec && defined $afterDec)
     1302    #{
     1303        my $name = "CoordShort";
     1304        push (@{$section_ptr->{'metadata'}}, [$name, "$latBeforeDec$lat_direction $lngBeforeDec$lng_direction"]);
     1305           
     1306        for(my $i = 2; $i <= 4; $i++)
     1307        {
     1308            my $latDecPlaces = (length($latAfterDec) >= $i) ? substr($latAfterDec, 0, $i) : "";         
     1309            my $lngDecPlaces = (length($lngAfterDec) >= $i) ? substr($lngAfterDec, 0, $i) : "";
     1310
     1311            push (@{$section_ptr->{'metadata'}}, [$name,
     1312                    $latBeforeDec . $lat_direction. $latDecPlaces . " " . $lngBeforeDec . $lng_direction. $lngDecPlaces]);
     1313           
     1314        }
     1315           
     1316        #Only add the metadata if it has not already been added
     1317        #my $metaMap = $self->get_metadata_hashmap($section); ### TODO: metaMap not used. Unnecesssary step? (Called function has no side-effects.)
     1318    #}
     1319
     1320
    11361321}
    11371322
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r32833 r33125  
    2424    if(jsonNodeDiv.length)
    2525    {
     26        console.log("@@@ JSON node div html: " + jsonNodeDiv.html());
     27       
    2628        var jsonNodes = eval(jsonNodeDiv.html());
    2729        if(jsonNodes && jsonNodes.length > 0)
     
    3133                _docList[jsonNodes[i].nodeID] = jsonNodes[i];
    3234                _docList.ids.push(jsonNodes[i].nodeID);
     35                console.log("@@@ JSON node: " + jsonNodes[i]);
    3336                createMarker(jsonNodes[i], true);
    3437            }
     
    3942            //$("#map_canvas").css({visibility:"hidden", height:"0px"});
    4043            $("#map_canvas").css({visibility:"hidden"});
     44            //console.log("suppressing hiding the map");
    4145        }
    4246    }
     
    8286function setUpMap()
    8387{
    84 
     88    //alert("@@@@in map-scripts::setUpMap()");
    8589   
    8690    var myOptions =
     
    9397   
    9498    if ($map_canvas.length > 0) {
     99        console.log("### map-scripts::setUpMap: map_canvas.exists");
    95100        _map = new google.maps.Map($map_canvas[0], myOptions);
    96101        google.maps.event.addListener(_map, 'bounds_changed', performSearchForMarkers);
     
    104109        return;
    105110    }
     111   
     112   
    106113   
    107114    _searchRunning = true;
     
    145152    if(lngDelta == 0.1){lngDelta = 1; lngPrecision = 0; }
    146153   
     154    /*
    147155    var query = "";
    148156    for(var i = 0; i <= Math.floor(latDistance / latDelta) + 1; i++)
     
    183191        }
    184192    }
     193    */
     194    var query = "";
     195    var iMax = Math.floor(latDistance / latDelta) + 1;
     196    var jMax = Math.floor(lngDistance / lngDelta) + 1;;
     197    for(var i = 0; i <= iMax; i++) //for(var i = 0; i <= Math.floor(latDistance / latDelta) + 1; i++)
     198    {
     199        for(var j = 0; j <= jMax; j++) //for(var j = 0; j <= Math.floor(lngDistance / lngDelta) + 1; j++)
     200        {
     201            //Some necessary variables
     202            var newLat = neLat - (latDelta * i);
     203            var newLatString = "" + newLat;
     204            var newLatTrunc;
     205            if(newLat < 0){newLatTrunc = Math.ceil(newLat);}
     206            else{newLatTrunc = Math.floor(newLat);}
     207           
     208            var newLng = neLng - (lngDelta * j);
     209            var newLngString = "" + newLng;
     210            var newLngTrunc;
     211            if(newLng < 0){newLngTrunc = Math.ceil(newLng);}
     212            else{newLngTrunc = Math.floor(newLng);}
     213
     214            //Construct query
     215            query += "(";
     216            query += "CS:\"" + coordToAbsDirected(newLatTrunc, "lat");
     217            //query += "CS:\"" + coordToAbsDirected(newLatTrunc, "lat") + "\" \"" + coordToAbsDirected(newLngTrunc, "lng") + "\""; //query += "LA:" + coordToAbsDirected(newLatTrunc, "lat");
     218            if(latDelta != 1)
     219            {
     220                query += newLatString.substring(newLatString.indexOf(".") + 1, newLatString.indexOf(".") + latPrecision + 1);
     221            }
     222            query += " ";
     223            //query += "+AND+";
     224           
     225            //query += "LN:" + coordToAbsDirected(newLngTrunc, "lng");
     226            query += coordToAbsDirected(newLngTrunc, "lng");
     227            if(lngDelta != 1)
     228            {
     229                query += newLngString.substring(newLngString.indexOf(".") + 1, newLngString.indexOf(".") + lngPrecision + 1);
     230            }
     231            query += "\"";         
     232            query += ")";
     233
     234            //if(i != (Math.floor(latDistance / latDelta) + 1) || j != (Math.floor(lngDistance / lngDelta) + 1)){ query += "+OR+"; }
     235            if(i != iMax || j != jMax){ query += "+OR+"; }
     236        }
     237    }
     238   
     239    // This works, why not from the double loop above?
     240    //query = "(CS:\"" + coordToAbsDirected(newLatTrunc, "lat") + " " + coordToAbsDirected(newLngTrunc, "lng") + "\")";
     241    //alert("@@@@in map-scripts::performSearchForMarkers() - query: " + query);
    185242   
    186243    //var url = gs.xsltParams.library_name + "?a=q&s=RawQuery&rt=rd&c=" + gs.cgiParams.c + "&s1.rawquery=" + query + "&excerptid=jsonNodes";
     
    196253            var startIndex = responseText.indexOf(">");
    197254            var endIndex = responseText.indexOf("</");
     255
     256            console.log("@@@@ performSearch, got response: " + responseText);
    198257
    199258            var jsonNodes = eval(responseText.substring(startIndex+1, endIndex));
     
    278337        }
    279338
     339        if(!doc.lat) {
     340            var coordInfo = getLatLngForCoord(doc.coord);
     341            bounds.extend(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
     342        }
     343        else {
    280344            bounds.extend(new google.maps.LatLng(doc.lat, doc.lng));
     345        }
    281346    }
    282347   
     
    291356}
    292357
     358function getLatLngForCoord(coord) {
     359   
     360    // https://stackoverflow.com/questions/2559318/how-to-check-for-an-undefined-or-null-variable-in-javascript
     361    if(!coord) {
     362         // some_variable is either null, undefined, 0, NaN, false, or an empty string
     363        console.log("@@@@ In map-scripts::getLatLngForCoord(): no or invalid coord info");
     364        return null;
     365    }
     366   
     367    // coord is of the form: "37S77 157E53"
     368    // lat will be 37S77, lng 157E53.
     369    var indexOfSpace = coord.indexOf(" ");
     370    if(indexOfSpace === -1) {
     371        console.log("@@@@ In map-scripts::getLatLngForCoord(): bad format for coord  " + coord);
     372        return null;
     373    }
     374    var latitude = coord.substring(0, indexOfSpace);
     375    var longitude = coord.substring(indexOfSpace+1);
     376    return {lat: latitude, lng: longitude}; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects
     377}
     378
    293379function loopThroughMarkers()
    294380{
     
    363449            gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Latitude", null, lat, null, "override", function(){callbackFunction();});
    364450            gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Longitude", null, lng, null, "override", function(){callbackFunction();});
     451            gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Coordinate", null, lat + " " + lng, null, "override", function(){callbackFunction();});
    365452            console.log("NodeID: " + nodeID);
    366453            console.log("GPS Click handler in collection:" + collection + " in site: " + site_name + " for Doc: " + nodeID + "(" + lat + "," + lng + ")");
     
    376463        clearInterval(_intervalHandle);
    377464        _intervalHandle = null;
    378         _map.panTo(new google.maps.LatLng(doc.lat, doc.lng));
     465        if(!doc.lat) {
     466            var coordInfo = getLatLngForCoord(doc.coord);
     467            _map.panTo(new google.maps.LatLng(coordInfo.lat, coordInfo.lng));
     468        } else {
     469            _map.panTo(new google.maps.LatLng(doc.lat, doc.lng));
     470        }
    379471        clearAllInfoBoxes();
    380472        doc.marker.markerInfo.open(_map, doc.marker);
     
    398490function createMarker(doc, mainMarker)
    399491{
    400     var pos = new google.maps.LatLng(doc.lat,doc.lng);
     492    var pos;
     493    if(doc.lat) {
     494        pos = new google.maps.LatLng(doc.lat,doc.lng);
     495    } else {
     496        var coordInfo = getLatLngForCoord(doc.coord);           
     497        pos = new google.maps.LatLng(coordInfo.lat,coordInfo.lng);
     498    }
     499   
    401500   
    402501    var docEdit = (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit']));
     
    525624}
    526625
     626function performDistanceSearchWithCoordinates(id, coord, degrees)
     627{
     628    var coordInfo = getLatLngForCoord(doc.coord);
     629    if(!coordInfo) {
     630        console.log("@@@ ERROR in map-scripts::performDistanceSearchWithCoordinates: coordInfo is null");       
     631    }
     632    performDistanceSearch(id, coordInfo.lat, coordInfo.lng, degrees);
     633}
     634
    527635function performDistanceSearch(id, lat, lng, degrees)
    528636{
  • main/trunk/greenstone3/web/interfaces/default/transform/map-tools.xsl

    r31550 r33125  
    1212    <td style="padding-left:5px; padding-right:5px;" valign="top">
    1313      <a href="javascript:focusDocument('{@nodeID}');">
    14     <img src="interfaces/default/images/map_marker.png"/>
     14    <img src="interfaces/{$interface_name}/images/map_marker.png"/>
    1515      </a>
    1616    </td>
     
    2121      <xsl:text>[</xsl:text>
    2222      <xsl:for-each select="//documentNode">
    23     <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
     23    <xsl:if test="(metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']) or metadataList/metadata[@name = 'Coordinate']">
    2424      <xsl:text>{</xsl:text>
    2525      <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text>
     
    2929      <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
    3030      <xsl:text disable-output-escaping="yes">",</xsl:text>
    31       <xsl:text disable-output-escaping="yes">"lat":</xsl:text>
    32       <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/>
    33       <xsl:text>,</xsl:text>
    34       <xsl:text disable-output-escaping="yes">"lng":</xsl:text>
    35       <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
     31      <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
     32          <xsl:text disable-output-escaping="yes">"lat":</xsl:text>
     33          <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/>
     34          <xsl:text>,</xsl:text>
     35          <xsl:text disable-output-escaping="yes">"lng":</xsl:text>
     36          <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
     37      </xsl:if>
     38      <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
     39        <xsl:text disable-output-escaping="yes">"coord":"</xsl:text>       
     40        <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Coordinate']"/>
     41        <xsl:text disable-output-escaping="yes">"</xsl:text>
     42      </xsl:if>
    3643      <xsl:text>}</xsl:text>
    3744      <xsl:if test="not(position() = count(//documentNode))">
     
    4653    <gsf:metadata name="Latitude" hidden="true"/>
    4754    <gsf:metadata name="Longitude" hidden="true"/>
     55    <gsf:metadata name="Coordinate" hidden="true"/>
     56    <gsf:metadata name="GPS.mapOverlay" hidden="true"/>
    4857<!--  these were included in version in query. don't think we need them...
    4958    <gsf:metadata name="Image" hidden="true"/>
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl

    r32626 r33125  
    300300  <xsl:template name="documentNodePost">
    301301    <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
    302       <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude']">
     302      <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude' or @name='Coordinate']">
    303303    <xsl:call-template name="mapFeaturesIcon"/>
    304304      </xsl:if>
    305305    </xsl:if>
    306306
    307 
     307    <!-- TODO: anything equivalent for Coordinate metadata? -->
    308308    <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
    309309      <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl

    r33095 r33125  
    844844                <xsl:when test="count(//documentNode) > 0">
    845845                    <xsl:for-each select="//documentNode">
    846                         <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
     846                        <xsl:if test="(metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']) or metadataList/metadata[@name = 'Coordinate']">
    847847                            <xsl:text>{</xsl:text>
    848848                            <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text>
    849849                            <xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
    850                             <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
    851                             <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
     850                            <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
     851                                <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
     852                                <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
     853                            </xsl:if>
     854                            <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
     855                                <xsl:text disable-output-escaping="yes">"coord":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Coordinate']"/>
     856                                <xsl:text disable-output-escaping="yes">"</xsl:text>
     857                            </xsl:if>
    852858                            <xsl:text>}</xsl:text>
    853859                            <xsl:if test="not(position() = count(//documentNode))">
     
    860866                <xsl:otherwise>
    861867                    <xsl:for-each select="/page/pageResponse/document">
    862                         <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
     868                        <xsl:if test="(metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']) or metadataList/metadata[@name = 'Coordinate']">
    863869                            <xsl:text>{</xsl:text>
    864870                            <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@selectedNode"/><xsl:text disable-output-escaping="yes">",</xsl:text>
    865871                            <xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
    866                             <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
    867                             <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
     872                            <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
     873                                <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
     874                                <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
     875                            </xsl:if>
     876                            <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
     877                                <xsl:text disable-output-escaping="yes">"coord":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Coordinate']"/>
     878                                <xsl:text disable-output-escaping="yes">"</xsl:text>
     879                            </xsl:if>
    868880                            <xsl:text>}</xsl:text>
    869881                        </xsl:if>
     
    893905            </div>
    894906        </xsl:if>
     907       
     908        <xsl:if test="metadataList/metadata[@name = 'Coordinate']">
     909            <div style="background:#BBFFBB; padding: 5px; margin:0px auto; width:890px;">
     910                <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.map_nearby_docs')"/>
     911                <img id="nearbyDocumentsToggle" style="margin-left:5px;" src="interfaces/{$interface_name}/images/expand.png">
     912                    <xsl:attribute name="onclick">
     913                        <xsl:text>performDistanceSearchWithCoordinates('</xsl:text>
     914                        <xsl:value-of select="@nodeID"/>
     915                        <xsl:text>', '</xsl:text>
     916                        <gsf:metadata name="Coordinate"/>
     917                        <xsl:text>', 2);</xsl:text>
     918                    </xsl:attribute>
     919                </img>
     920                <div id="nearbyDocuments"><xsl:text> </xsl:text></div>
     921            </div>
     922        </xsl:if>
    895923    </xsl:template>
    896924</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.