LANIS Update:

- polygon features area label format (threshold, thousands seperator)
- polygon features area output in bottom attribution text
This commit is contained in:
sebastianpauli 2023-06-14 13:30:04 +02:00
parent 6ed0dd8ec8
commit 2014ac31ad
5 changed files with 66 additions and 12 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Sebastian Pauli
Copyright (c) 2022-2023 Sebastian Pauli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -104,7 +104,7 @@
{ "folder": 2, "type": "WFS", "title": "Überschwemmungsgebiete WFS Test", "url": "http://213.139.159.34:80/geoserver/uesg/wfs?", "name": "uesg:uesg_gesetzlich", "outputFormat": "application/json" },
{ "folder": 3, "type": "WMS", "title": "TopPlusOpen", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": false },
{ "folder": 3, "type": "OSM", "title": "Open Street Map", "attribution": "OSM", "active": true, "minZoom": 8, "maxZoom": 11 }
{ "folder": 3, "type": "OSM", "title": "Open Street Map", "attribution": "OSM", "active": true, "minZoom": 1, "maxZoom": 20 }
],
"folders":

View File

@ -7,11 +7,11 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>NetGIS Client</title>
<title>OWS Demo | NetGIS Client</title>
<!-- Library Styles -->
<link rel="stylesheet" type="text/css" href="/libs/fontawesome/5.12.0/css/all.min.css" />
<link rel="stylesheet" type="text/css" href="/libs/openlayers/6.14.1/ol.css" />
<link rel="stylesheet" type="text/css" href="/libs/openlayers/7.2.2/ol.css" />
<!-- Custom Styles -->
<link rel="stylesheet" type="text/css" href="../src/netgis/Client.css" />
@ -19,6 +19,7 @@
<link rel="stylesheet" type="text/css" href="../src/netgis/Attribution.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Controls.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/LayerTree.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/SearchParcel.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Toolbar.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Menu.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Modal.css" />
@ -49,7 +50,14 @@
</main>
<!-- Library Scripts -->
<script type="text/javascript" src="/libs/openlayers/6.14.1/ol.js"></script>
<script type="text/javascript" src="/libs/openlayers/7.2.2/ol.js"></script>
<script type="text/javascript" src="/libs/proj4js/2.6.0/proj4.js"></script>
<script type="text/javascript" src="/libs/jsts/1.6.1/jsts.min.js"></script>
<script type="text/javascript" src="/libs/shapefilejs/4.0.2/shp.js"></script>
<script type="text/javascript" src="/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script type="text/javascript" src="/libs/gifjs/0.2.0/gif.js"></script>
<script type="text/javascript" src="/libs/sqljs/1.8.0/sql.js"></script>
<script type="text/javascript" src="/libs/geopackage/4.2.3/geopackage.min.js"></script>
<!-- Custom Scripts -->
<script type="text/javascript" src="../src/netgis/Util.js"></script>
@ -66,6 +74,7 @@
<script type="text/javascript" src="../src/netgis/Toolbar.js"></script>
<script type="text/javascript" src="../src/netgis/Modal.js"></script>
<script type="text/javascript" src="../src/netgis/SearchPlace.js"></script>
<script type="text/javascript" src="../src/netgis/SearchParcel.js"></script>
<script type="text/javascript" src="../src/netgis/OWS.js"></script>
<script type="text/javascript" src="../src/netgis/SLD.js"></script>

View File

@ -26,6 +26,7 @@ netgis.Attribution.prototype.load = function()
this.client.on( netgis.Events.CONTEXT_UPDATE, this.onContextUpdate.bind( this ) );
this.client.on( netgis.Events.LAYER_SHOW, this.onLayerShow.bind( this ) );
this.client.on( netgis.Events.LAYER_HIDE, this.onLayerHide.bind( this ) );
this.client.on( netgis.Events.EDIT_FEATURES_CHANGE, this.onEditFeaturesChange.bind( this ) );
};
netgis.Attribution.prototype.update = function()
@ -83,4 +84,28 @@ netgis.Attribution.prototype.onLayerHide = function( e )
}
this.update();
};
netgis.Attribution.prototype.onEditFeaturesChange = function( e )
{
// Update Area
var areaLabel = "Zeichnungsfläche: ";
for ( var i = 0; i < this.items.length; i++ )
{
var item = this.items[ i ];
if ( item.search( areaLabel ) > -1 )
{
this.items.splice( i, 1 );
break;
}
}
if ( e.area && e.area > 0.0 )
{
var areaItem = areaLabel + netgis.util.formatArea( e.area, true );
this.items.push( areaItem );
this.update();
}
};

View File

@ -153,27 +153,42 @@ netgis.util =
return timestamp;
};
/**
* @returns {String} The users language locale string (defaults to German)
*/
var getUserLanguage = function()
{
var lang = navigator.language || "de-DE";
return lang;
};
/*
* @param {Number} area Raw Area in Square Meters
* @param {Boolean} decimals Output Rounded Decimals
* @param {Number} threshold Threshold for normal (square meters) vs. large (square kilometers) values
* @param {Boolean} seperate Use thousands seperators
* @returns {String} Formatted Area String (Square Meters/Square Kilometers)
*/
var formatArea = function( area, decimals )
var formatArea = function( area, decimals, threshold, seperate )
{
var output;
// Normal / Large Value
var large = ( area > 10000 );
threshold = threshold || 100000;
var large = ( area > threshold );
// Round Value
var i = 0;
if ( large )
{
var METERS_PER_KILOMETER = 1000000;
if ( decimals )
i = Math.round( area / 1000000 * 1000 ) / 1000;
i = Math.round( area / METERS_PER_KILOMETER * 1000 ) / 1000;
else
i = Math.round( area / 1000000 );
i = Math.round( area / METERS_PER_KILOMETER );
}
else
{
@ -185,10 +200,14 @@ netgis.util =
if ( i === 0 ) large = false;
// Build String
output = i + ( large ? " qkm" : " qm" );
// Thousands Seperators
seperate = seperate || true;
if ( seperate ) i = i.toLocaleString( getUserLanguage() );
//NOTE: HTML Superscript / Unicode (&sup2; etc.) not supported in OL Labels
// Build String
output = i + ( large ? " km²" : " m²" );
// NOTE: HTML Superscript / Unicode (&sup2; etc.) not supported in OL Labels
return output;
};
@ -208,6 +227,7 @@ netgis.util =
padstr: padstr,
merge: merge,
getTimeStamp: getTimeStamp,
getUserLanguage: getUserLanguage,
formatArea: formatArea
};