Quick first implementation of the new SearchParcel module.

This commit is contained in:
sebastianpauli 2022-08-26 17:56:12 +02:00
parent 284431acda
commit 7fd251fa63
14 changed files with 918 additions and 6 deletions

View File

@ -7,7 +7,7 @@
<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>Editor Demo | NetGIS Client</title>
<!-- Library Styles -->
<link rel="stylesheet" type="text/css" href="/libs/fontawesome/5.12.0/css/all.min.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" />
@ -71,6 +72,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>
@ -79,7 +81,13 @@
<!-- Implementation Script -->
<script type="text/javascript">
var client = new netgis.Client( "container" );
var config = netgis.Client.prototype.createDefaultConfig();
config.projections.push( [ "EPSG:25832", "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs" ] );
config.map.projection = "EPSG:25832";
config.map.center = [ 327642, 5514459 ];
config.map.zoom = 12;
var client = new netgis.Client( "container", config );
client.debug = true;
</script>

213
demo/lanis.html Normal file
View File

@ -0,0 +1,213 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<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>LANIS 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" />
<!-- Custom Styles -->
<link rel="stylesheet" type="text/css" href="../src/netgis/Client.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Map.css" />
<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" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Theme.css" />
<!--<link rel="stylesheet" type="text/css" href="../dist/netgis.min.css" />-->
<!-- Implementation Style -->
<style>
#container
{
position: absolute;
left: 0mm;
top: 0mm;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<!-- Client Container -->
<main id="container" data-editable="true">
</main>
<input type="hidden" id="netgis-storage" name="output" />
<!-- Library Scripts -->
<script type="text/javascript" src="/libs/openlayers/6.14.1/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>
<!-- Custom Scripts -->
<script type="text/javascript" src="../src/netgis/Util.js"></script>
<script type="text/javascript" src="../src/netgis/Events.js"></script>
<script type="text/javascript" src="../src/netgis/Modes.js"></script>
<script type="text/javascript" src="../src/netgis/LayerTypes.js"></script>
<script type="text/javascript" src="../src/netgis/Client.js"></script>
<script type="text/javascript" src="../src/netgis/Menu.js"></script>
<script type="text/javascript" src="../src/netgis/Map.js"></script>
<script type="text/javascript" src="../src/netgis/MapOpenLayers.js"></script>
<script type="text/javascript" src="../src/netgis/Controls.js"></script>
<script type="text/javascript" src="../src/netgis/Attribution.js"></script>
<script type="text/javascript" src="../src/netgis/LayerTree.js"></script>
<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>
<!--<script type="text/javascript" src="../dist/netgis.min.js"></script>-->
<!-- Implementation Script -->
<script type="text/javascript">
// Demo Config
var config =
{
"layers":
[
{ "folder": 0, "type": "WMS", "title": "KOM Punkte", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_p&", "name": "kom_p" },
{ "folder": 0, "type": "WMS", "title": "KOM Linien", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_l&", "name": "kom_l" },
{ "folder": 0, "type": "WMS", "title": "KOM Flächen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_f&", "name": "kom_f" },
{ "folder": 1, "type": "WMS", "title": "Lagebezeichnungen", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Lagebezeichnungen" },
{ "folder": 1, "type": "WMS", "title": "Flurstücke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Flurstueck", "username": "abc", "password": "123" },
{ "folder": 1, "type": "WMS", "title": "Gebäude / Bauwerke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "GebaeudeBauwerke" },
{ "folder": 1, "type": "WMS", "title": "Nutzung", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Nutzung", "active": true },
{ "folder": 2, "type": "WFS", "title": "Überschwemmungsgebiete WFS Test", "url": "http://213.139.159.34:80/geoserver/uesg/wfs?", "name": "uesg:uesg_gesetzlich" },
{ "folder": 3, "type": "WMS", "title": "TopPlusOpen", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": true },
{ "folder": 3, "type": "OSM", "title": "Open Street Map", "attribution": "OSM" }
],
"folders":
[
{ "title": "KOM Kompensationsmaßnahmen", "parent": -1 },
{ "title": "ALKIS Liegenschaften", "parent": -1 },
{ "title": "Test", "parent": -1 },
{ "title": "Hintergrund", "parent": -1 }
],
"projections":
[
[ "EPSG:25832", "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs" ]
],
"map":
{
"projection": "EPSG:25832",
"center": [ 385000, 5543000 ],
"minZoom": 5,
"maxZoom": 19,
"zoom": 8,
"attribution": "LANIS RLP"
},
"output":
{
"id": "netgis-storage"
},
"search":
{
"url": "./proxy.php?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}"
},
"searchParcel":
{
"nameURL": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}",
"parcelURL": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json"
},
"export":
{
"logo": "./assets/logo.png",
"gifWebWorker": "/libs/gifjs/0.2.0/gif.worker.js",
"defaultFilename": "Export",
"defaultMargin": 10
},
"tools":
{
"buffer":
{
"defaultRadius": 10,
"defaultSegments": 3
}
},
"styles":
{
"editLayer":
{
"fill": "rgba( 255, 0, 0, 0.5 )",
"stroke": "#ff0000",
"strokeWidth": 3,
"pointRadius": 6
},
"select":
{
"fill": "rgba( 0, 127, 255, 0.5 )",
"stroke": "#007fff",
"strokeWidth": 3,
"pointRadius": 6
},
"sketch":
{
"fill": "rgba( 0, 127, 0, 0.5 )",
"stroke": "#007f00",
"strokeWidth": 3,
"pointRadius": 6
},
"modify":
{
"fill": "rgba( 0, 127, 0, 0.5 )",
"stroke": "#007f00",
"strokeWidth": 3,
"pointRadius": 6
},
"parcel":
{
"fill": "rgba( 127, 255, 255, 0.5 )",
"stroke": "#7fffff",
"strokeWidth": 3
}
}
};
// Create Client Instance
var client = new netgis.Client( "container", config );
client.debug = true;
</script>
</body>
</html>

24
demo/proxy.php Normal file
View File

@ -0,0 +1,24 @@
<?php
// URL
$query = urldecode( $_SERVER[ "QUERY_STRING" ] );
// Open Session
$session = curl_init( $query );
// Only return contents, no headers
curl_setopt( $session, CURLOPT_HEADER, false );
curl_setopt( $session, CURLOPT_RETURNTRANSFER, true );
// Execute
$response = curl_exec( $session );
// Output
header( "Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept" );
header( "Access-Control-Allow-Origin: *" );
header( "Content-Type: application/json" );
echo $response;
// Done
curl_close( $session );

View File

@ -22,7 +22,7 @@
font-size: 12mm;
}
.netgis-client .netgis-loader.netgis-hide
.netgis-client .netgis-hide
{
display: none;
}

View File

@ -14,7 +14,7 @@ var netgis = netgis || {};
*/
netgis.Client = function( container, config )
{
this.build = "20220704";
this.build = "20220826";
this.debug = false;
if ( netgis.util.isString( container ) )
@ -83,6 +83,8 @@ netgis.Client = function( container, config )
netgis.Client.prototype.createDefaultConfig = function()
{
//TODO: should this be a static method of a config module ?
var config =
{
map:
@ -110,7 +112,8 @@ netgis.Client.prototype.createDefaultConfig = function()
editLayer: { fill: "rgba( 255, 0, 0, 0.5 )", stroke: "#ff0000", strokeWidth: 3, pointRadius: 6 },
select: { fill: "rgba( 0, 127, 255, 0.5 )", stroke: "#007fff", strokeWidth: 3, pointRadius: 6 },
sketch: { fill: "rgba( 0, 127, 0, 0.5 )", stroke: "#007f00", strokeWidth: 3, pointRadius: 6 },
modify: { fill: "rgba( 0, 127, 0, 0.5 )", stroke: "#007f00", strokeWidth: 3, pointRadius: 6 }
modify: { fill: "rgba( 0, 127, 0, 0.5 )", stroke: "#007f00", strokeWidth: 3, pointRadius: 6 },
parcel: { fill: "rgba( 127, 255, 255, 0.5 )", stroke: "#7fffff", strokeWidth: 3 }
}
};
@ -164,6 +167,7 @@ netgis.Client.prototype.createModules = function()
this.add( new netgis.Toolbar() );
this.add( new netgis.Menu() );
this.add( new netgis.SearchPlace() );
this.add( new netgis.SearchParcel() );
this.add( new netgis.Modal() );
};

View File

@ -18,6 +18,7 @@ netgis.Events = Object.freeze
LAYER_HIDE: "LAYER_HIDE",
LAYER_CREATED: "LAYER_CREATED",
MAP_ZOOM_WKT: "MAP_ZOOM_WKT",
MAP_SET_EXTENT: "MAP_SET_EXTENT",
MAP_CHANGE_ZOOM: "MAP_CHANGE_ZOOM",
@ -33,6 +34,9 @@ netgis.Events = Object.freeze
SEARCH_PLACE_REQUEST: "SEARCH_PLACE_REQUEST",
SEARCH_PLACE_RESPONSE: "SEARCH_PLACE_RESPONSE",
PARCEL_SHOW_PREVIEW: "PARCEL_SHOW_PREVIEW",
PARCEL_HIDE_PREVIEW: "PARCEL_HIDE_PREVIEW",
BUFFER_CHANGE: "BUFFER_CHANGE",
BUFFER_ACCEPT: "BUFFER_ACCEPT",
BUFFER_CANCEL: "BUFFER_CANCEL",
@ -47,6 +51,7 @@ netgis.Events = Object.freeze
IMPORT_SHAPEFILE: "IMPORT_SHAPEFILE",
IMPORT_GEOJSON: "IMPORT_GEOJSON",
IMPORT_GML: "IMPORT_GML",
IMPORT_WKT: "IMPORT_WKT",
EXPORT_PDF_SHOW: "EXPORT_PDF_SHOW",
EXPORT_JPEG_SHOW: "EXPORT_JPEG_SHOW",

View File

@ -1,3 +1,6 @@
/* TODO: refactor into common panel class */
.netgis-layer-list
{
position: absolute;
@ -16,6 +19,8 @@
.netgis-layer-list.netgis-hide
{
display: initial;
-webkit-transform: translateX( 110% );
transform: translateX( 110% );
transition: transform 150ms ease;

View File

@ -2,6 +2,9 @@
var netgis = netgis || {};
//TODO: refactor common panel class
//TODO: refactor common tree view class
netgis.LayerTree = function()
{
this.client = null;
@ -27,6 +30,9 @@ netgis.LayerTree.prototype.load = function()
this.client.on( netgis.Events.LAYER_LIST_TOGGLE, this.onLayerListToggle.bind( this ) );
this.client.on( netgis.Events.LAYER_CREATED, this.onLayerCreated.bind( this ) );
this.client.on( netgis.Events.EDIT_FEATURES_CHANGE, this.onEditFeaturesChange.bind( this ) );
//TODO: kind of hack to hide if parcel search open
this.client.on( netgis.Events.SET_MODE, this.onSetMode.bind( this ) );
};
netgis.LayerTree.prototype.clearAll = function()
@ -377,4 +383,12 @@ netgis.LayerTree.prototype.onEditFeaturesChange = function( e )
this.client.invoke( netgis.Events.LAYER_SHOW, { id: id } );
}
};
};
netgis.LayerTree.prototype.onSetMode = function( e )
{
if ( e === netgis.Modes.SEARCH_PARCEL )
{
this.root.classList.add( "netgis-hide" );
}
};

View File

@ -20,6 +20,8 @@ netgis.MapOpenLayers = function()
this.snap = null;
this.snapFeatures = null;
this.editLayer = null;
this.parcelLayer = null;
this.hover = null;
this.selected = null;
this.sketch = null;
@ -65,6 +67,7 @@ netgis.MapOpenLayers.prototype.load = function()
this.client.on( netgis.Events.SNAP_OFF, this.onSnapOff.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.MAP_ZOOM_WKT, this.onZoomWKT.bind( this ) );
this.client.on( netgis.Events.MAP_SET_EXTENT, this.onSetExtent.bind( this ) );
this.client.on( netgis.Events.MAP_CHANGE_ZOOM, this.onChangeZoom.bind( this ) );
this.client.on( netgis.Events.BUFFER_CHANGE, this.onBufferChange.bind( this ) );
@ -73,10 +76,13 @@ netgis.MapOpenLayers.prototype.load = function()
this.client.on( netgis.Events.IMPORT_GEOJSON, this.onImportGeoJSON.bind( this ) );
this.client.on( netgis.Events.IMPORT_GML, this.onImportGML.bind( this ) );
this.client.on( netgis.Events.IMPORT_SHAPEFILE, this.onImportShapefile.bind( this ) );
this.client.on( netgis.Events.IMPORT_WKT, this.onImportWKT.bind( this ) );
this.client.on( netgis.Events.EXPORT_PDF, this.onExportPDF.bind( this ) );
this.client.on( netgis.Events.EXPORT_JPEG, this.onExportJPEG.bind( this ) );
this.client.on( netgis.Events.EXPORT_PNG, this.onExportPNG.bind( this ) );
this.client.on( netgis.Events.EXPORT_GIF, this.onExportGIF.bind( this ) );
this.client.on( netgis.Events.PARCEL_SHOW_PREVIEW, this.onParcelShowPreview.bind( this ) );
this.client.on( netgis.Events.PARCEL_HIDE_PREVIEW, this.onParcelHidePreview.bind( this ) );
};
netgis.MapOpenLayers.prototype.createMap = function()
@ -129,9 +135,14 @@ netgis.MapOpenLayers.prototype.createMap = function()
netgis.MapOpenLayers.prototype.createDefaultLayers = function()
{
//TODO: why id as z index ?
this.editLayer = new ol.layer.Vector( { source: new ol.source.Vector( { features: [] } ), style: this.styleEdit.bind( this ), zIndex: this.editLayerID } );
this.map.addLayer( this.editLayer );
this.parcelLayer = new ol.layer.Vector( { source: new ol.source.Vector( { features: [] } ), style: this.styleParcel.bind( this ), zIndex: this.editLayerID + 10 } );
this.map.addLayer( this.parcelLayer );
this.editEventsOn();
};
@ -240,6 +251,8 @@ netgis.MapOpenLayers.prototype.createInteractions = function()
new ol.interaction.DragPan(),
new ol.interaction.MouseWheelZoom()
];
this.interactions[ netgis.Modes.SEARCH_PARCEL ] = this.interactions[ netgis.Modes.VIEW ];
};
netgis.MapOpenLayers.prototype.createLayer = function( data )
@ -477,6 +490,22 @@ netgis.MapOpenLayers.prototype.styleSketch = function( feature )
return [ style, vertex ];
};
netgis.MapOpenLayers.prototype.styleParcel = function()
{
//var radius = this.client.config.styles.editLayer.pointRadius;
var style = new ol.style.Style
(
{
//image: new ol.style.Circle( { radius: radius, fill: new ol.style.Fill( { color: this.client.config.styles.editLayer.stroke } ) } ),
fill: new ol.style.Fill( { color: this.client.config.styles.parcel.fill } ),
stroke: new ol.style.Stroke( { color: this.client.config.styles.parcel.stroke, width: this.client.config.styles.parcel.strokeWidth } )
}
);
return style;
};
netgis.MapOpenLayers.prototype.getGeometryPoints = function( feature )
{
var geometry = feature.getGeometry();
@ -593,6 +622,8 @@ netgis.MapOpenLayers.prototype.setMode = function( mode )
}
}
//TODO: set to default pan interactions when none found for mode ?
if ( this.snap )
{
if ( mode === netgis.Modes.DRAW_POINTS || mode === netgis.Modes.DRAW_LINES || mode === netgis.Modes.DRAW_POLYGONS )
@ -813,6 +844,17 @@ netgis.MapOpenLayers.prototype.onChangeZoom = function( e )
this.view.animate( { zoom: this.view.getZoom() + delta, duration: 200 } );
};
netgis.MapOpenLayers.prototype.onZoomWKT = function( e )
{
var parser = new ol.format.WKT();
var geom = parser.readGeometry( e );
var padding = 40;
this.view.fit( geom, { duration: 300, padding: [ padding, padding, padding, padding ] } );
//TODO: take visible panels into account when zooming
};
netgis.MapOpenLayers.prototype.onPointerMove = function( e )
{
//var pixel = e.pixel;
@ -1284,6 +1326,15 @@ netgis.MapOpenLayers.prototype.addImportedFeatures = function( features )
*/
};
netgis.MapOpenLayers.prototype.onImportWKT = function( e )
{
var parser = new ol.format.WKT();
var geom = parser.readGeometry( e );
var feature = new ol.Feature( { geometry: geom } );
this.addImportedFeatures( [ feature ] );
};
netgis.MapOpenLayers.prototype.onExportPDF = function( e )
{
this.exportImage( "pdf", e.resx, e.resy, e.mode, e.margin );
@ -1304,6 +1355,21 @@ netgis.MapOpenLayers.prototype.onExportGIF = function( e )
this.exportImage( "gif", e.resx, e.resy );
};
netgis.MapOpenLayers.prototype.onParcelShowPreview = function( e )
{
var parser = new ol.format.WKT();
var geom = parser.readGeometry( e.geom );
var feature = new ol.Feature( { geometry: geom } );
this.parcelLayer.getSource().clear();
this.parcelLayer.getSource().addFeature( feature );
};
netgis.MapOpenLayers.prototype.onParcelHidePreview = function( e )
{
this.parcelLayer.getSource().clear();
};
netgis.MapOpenLayers.prototype.getWidth = function()
{
return this.map.getSize()[ 0 ];

View File

@ -28,6 +28,10 @@ netgis.Menu.prototype.load = function()
////this.root.appendChild( search );
wrapper.appendChild( search );
var searchParcel = this.createButton( 'Flurstücke<i class="fas fa-vector-square" style="position: relative; top: 0.3mm;"></i>', true );
searchParcel.addEventListener( "click", this.onSearchParcelClick.bind( this ) );
wrapper.appendChild( searchParcel );
/*var title = this.createButton( '<span>GeoPortal</span>', false );
title.classList.remove( "netgis-hover-primary" ); //TODO: createText function?
//title.style.padding = "0mm";
@ -189,6 +193,11 @@ netgis.Menu.prototype.onSearchPlaceClick = function( e )
this.client.invoke( netgis.Events.SET_MODE, netgis.Modes.SEARCH_PLACE );
};
netgis.Menu.prototype.onSearchParcelClick = function( e )
{
this.client.invoke( netgis.Events.SET_MODE, netgis.Modes.SEARCH_PARCEL );
};
netgis.Menu.prototype.onSearchDataClick = function( e )
{
alert( "TODO: data search interface" );

View File

@ -21,6 +21,7 @@ netgis.Modes = Object.freeze
BUFFER_FEATURE_BEGIN: "BUFFER_FEATURE_BEGIN",
BUFFER_FEATURE_EDIT: "BUFFER_FEATURE_EDIT",
SEARCH_PLACE: "SEARCH_PLACE"
SEARCH_PLACE: "SEARCH_PLACE",
SEARCH_PARCEL: "SEARCH_PARCEL"
}
);

131
src/netgis/SearchParcel.css Normal file
View File

@ -0,0 +1,131 @@
/* TODO: refactor into common panel class */
.netgis-search-parcel
{
position: absolute;
right: 0mm;
width: 100%;
max-width: 100mm;
top: 12mm;
bottom: 0mm;
overflow: auto;
z-index: 200;
padding: 4mm;
-webkit-transform: none;
transform: none;
transition: transform 150ms ease;
}
.netgis-search-parcel.netgis-hide
{
display: initial;
-webkit-transform: translateX( 110% );
transform: translateX( 110% );
transition: transform 150ms ease;
will-change: transform;
}
.netgis-search-parcel h3
{
margin: 0mm;
margin-bottom: 4mm;
}
.netgis-search-parcel label
{
display: block;
margin: 3mm 0mm;
margin-bottom: 0mm;
cursor: pointer;
}
.netgis-search-parcel input
{
width: 100%;
height: 12mm;
margin: 3mm 0mm;
padding: 0mm 3mm;
}
.netgis-search-parcel .netgis-loader
{
width: 6mm;
height: 6mm;
top: 8mm;
right: 6mm;
font-size: 6mm;
}
.netgis-search-parcel ul
{
margin: 0mm;
padding: 0mm;
list-style-type: none;
}
.netgis-search-parcel li button
{
text-align: left;
}
.netgis-search-parcel button
{
display: block;
width: 100%;
height: 12mm;
padding: 0mm 3mm;
margin: 0mm;
}
.netgis-search-parcel .netgis-table-wrapper
{
width: 100%;
/*height: 144mm; /* 12mm * 12 */
max-height: 120mm;
margin-top: 4mm;
overflow: auto;
}
.netgis-search-parcel table
{
border-collapse: collapse;
white-space: nowrap;
}
.netgis-search-parcel tr
{
height: 12mm;
}
.netgis-search-parcel th, .netgis-search-parcel td
{
text-align: left;
padding: 0mm 3mm;
}
.netgis-search-parcel td
{
cursor: pointer;
}
.netgis-search-parcel td:first-child
{
padding: 0mm;
}
.netgis-search-parcel table button
{
display: inline-block;
width: 12mm;
height: 12mm;
}
.netgis-search-parcel p
{
margin: 4mm 3mm;
font-style: italic;
}

431
src/netgis/SearchParcel.js Normal file
View File

@ -0,0 +1,431 @@
"use strict";
var netgis = netgis || {};
netgis.SearchParcel = function()
{
this.client = null;
};
netgis.SearchParcel.prototype.load = function()
{
this.root = document.createElement( "section" );
this.root.className = "netgis-search-parcel netgis-dialog netgis-shadow netgis-hide";
// Head
var head = document.createElement( "h3" );
head.innerHTML = "Flurstücks-Suche:";
this.root.appendChild( head );
// Form
var form = document.createElement( "div" );
this.root.appendChild( form );
// Name Input ( "Gemarkung" )
var nameLabel = this.createInput( "Gemarkungsname:" );
nameLabel.style.position = "relative";
form.appendChild( nameLabel );
this.nameInput = nameLabel.children[ 0 ];
this.nameInput.setAttribute( "title", "ENTER: Auswählen, ESCAPE: Zurücksetzen" );
this.nameInput.addEventListener( "keyup", this.onInputNameKey.bind( this ) );
this.nameLoader = document.createElement( "div" );
this.nameLoader.className = "netgis-loader netgis-text-primary netgis-hide";
this.nameLoader.innerHTML = "<i class='fas fa-spinner'></i>";
nameLabel.appendChild( this.nameLoader );
// Name Results
this.nameList = document.createElement( "ul" );
form.appendChild( this.nameList );
// District Input ( "Gemarkung" )
var districtLabel = this.createInput( "Gemarkungsnummer:" );
this.districtInput = districtLabel.children[ 0 ];
form.appendChild( districtLabel );
// Field Input ( "Flur" )
var fieldLabel = this.createInput( "Flurnummer:" );
this.fieldInput = fieldLabel.children[ 0 ];
form.appendChild( fieldLabel );
// Parcel Input ( "Flurstück" )
var parcelLabel = this.createInput( "Flurstücksnummer (Zähler/Nenner):" );
this.parcelInputA = parcelLabel.children[ 0 ];
this.parcelInputA.style.width = "48%";
this.parcelInputB = this.parcelInputA.cloneNode( true );
this.parcelInputB.style.marginLeft = "4%";
parcelLabel.appendChild( this.parcelInputB );
form.appendChild( parcelLabel );
// Parcel Search
var parcelButton = document.createElement( "button" );
parcelButton.setAttribute( "type", "button" );
parcelButton.addEventListener( "click", this.onParcelSearchClick.bind( this ) );
parcelButton.className = "netgis-primary netgis-hover-primary";
parcelButton.innerHTML = "Flurstücke suchen";
parcelButton.style.marginTop = "4mm";
form.appendChild( parcelButton );
// Parcel Results
this.parcelInfo = document.createElement( "p" );
form.appendChild( this.parcelInfo );
this.parcelTable = this.createTable( [ "", "Flur", "FS Zähler", "FS Nenner", "FKZ", "Fläche (qm)" ] );
this.parcelTable.classList.add( "netgis-hide" );
form.appendChild( this.parcelTable );
this.parcelList = this.parcelTable.getElementsByTagName( "tbody" )[ 0 ];
this.parcelReset = document.createElement( "button" );
this.parcelReset.setAttribute( "type", "button" );
this.parcelReset.addEventListener( "click", this.onParcelResetClick.bind( this ) );
this.parcelReset.className = "netgis-primary netgis-hover-primary";
this.parcelReset.innerHTML = "Zurücksetzen";
this.parcelReset.style.marginTop = "4mm";
form.appendChild( this.parcelReset );
// Initial State
this.reset();
// Test
this.requestParcel( "072856", "1" );
// Attach To Client
this.client.root.appendChild( this.root );
this.client.on( netgis.Events.SET_MODE, this.onSetMode.bind( this ) );
this.client.on( netgis.Events.LAYER_LIST_TOGGLE, this.onLayerListToggle.bind( this ) );
};
netgis.SearchParcel.prototype.createInput = function( title )
{
var label = document.createElement( "label" );
label.className = "netgis-hover-text-primary";
label.innerHTML = title;
var input = document.createElement( "input" );
input.setAttribute( "type", "text" );
label.appendChild( input );
return label;
};
netgis.SearchParcel.prototype.createNameItem = function( title )
{
var li = document.createElement( "li" );
var button = document.createElement( "button" );
button.setAttribute( "type", "button" );
button.addEventListener( "click", this.onNameItemClick.bind( this ) );
button.className = "netgis-text-primary netgis-hover-light";
button.innerHTML = title;
li.appendChild( button );
return li;
};
netgis.SearchParcel.prototype.createTable = function( columnNames )
{
var wrapper = document.createElement( "div" );
wrapper.className = "netgis-table-wrapper";
var table = document.createElement( "table" );
wrapper.appendChild( table );
// Head
var head = document.createElement( "thead" );
table.appendChild( head );
var row = document.createElement( "tr" );
row.className = "netgis-light";
row.style.position = "sticky";
head.appendChild( row );
for ( var i = 0; i < columnNames.length; i++ )
{
var th = document.createElement( "th" );
th.innerHTML = columnNames[ i ];
row.appendChild( th );
}
// Body
var body = document.createElement( "tbody" );
table.appendChild( body );
return wrapper;
};
netgis.SearchParcel.prototype.createParcelItem = function( field, parcelA, parcelB, id, area, bbox, geom )
{
//TODO: store geometry data on element vs. seperate data array ?
var tr = document.createElement( "tr" );
tr.className = "netgis-hover-light netgis-hover-text-primary";
tr.setAttribute( "title", "Klicken zum zoomen" );
tr.setAttribute( "data-bbox", bbox );
tr.setAttribute( "data-geom", geom );
tr.addEventListener( "mouseenter", this.onParcelEnter.bind( this ) );
tr.addEventListener( "mouseleave", this.onParcelLeave.bind( this ) );
tr.addEventListener( "click", this.onParcelClick.bind( this ) );
var buttonCell = document.createElement( "td" );
tr.appendChild( buttonCell );
var importButton = document.createElement( "button" );
importButton.setAttribute( "type", "button" );
importButton.setAttribute( "title", "Geometrie übernehmen" );
importButton.addEventListener( "click", this.onParcelImportClick.bind( this ) );
importButton.className = "netgis-text-primary netgis-hover-primary";
importButton.innerHTML = "<i class='fas fa-paste'></i>";
buttonCell.appendChild( importButton );
var fieldCell = document.createElement( "td" );
fieldCell.innerHTML = field;
tr.appendChild( fieldCell );
var parcelCellA = document.createElement( "td" );
parcelCellA.innerHTML = parcelA;
tr.appendChild( parcelCellA );
var parcelCellB = document.createElement( "td" );
parcelCellB.innerHTML = parcelB;
tr.appendChild( parcelCellB );
var idCell = document.createElement( "td" );
idCell.innerHTML = id;
tr.appendChild( idCell );
var areaCell = document.createElement( "td" );
areaCell.innerHTML = area;
tr.appendChild( areaCell );
return tr;
};
netgis.SearchParcel.prototype.reset = function()
{
this.nameLoader.classList.add( "netgis-hide" );
this.nameInput.value = "";
this.districtInput.value = "";
this.fieldInput.value = "";
this.parcelInputA.value = "";
this.parcelInputB.value = "";
this.nameList.innerHTML = "";
this.parcelInfo.innerHTML = "";
this.parcelList.innerHTML = "";
this.parcelTable.classList.add( "netgis-hide" );
this.parcelReset.classList.add( "netgis-hide" );
this.root.scrollTop = 0;
};
netgis.SearchParcel.prototype.onInputNameKey = function( e )
{
switch ( e.keyCode )
{
// Enter
case 13:
{
this.selectFirstName();
break;
}
// Escape
case 27:
{
this.reset();
break;
}
default:
{
this.requestName( this.nameInput.value.trim() );
break;
}
}
};
netgis.SearchParcel.prototype.requestName = function( query )
{
if ( this.nameDebounce ) window.clearTimeout( this.nameDebounce );
if ( query.length === 0 ) return;
/*var url = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}";
url = "/geoportal/client/proxy.php?" + url;*/
var url = this.client.config.searchParcel.nameURL;
url = netgis.util.replace( url, "{q}", window.encodeURIComponent( query ) );
this.nameDebounce = window.setTimeout( this.onInputNameDebounce.bind( this, url ), 200 );
this.nameLoader.classList.remove( "netgis-hide" );
};
netgis.SearchParcel.prototype.onInputNameDebounce = function( url )
{
netgis.util.request( url, this.onInputNameResponse.bind( this ) );
};
netgis.SearchParcel.prototype.onInputNameResponse = function( data )
{
this.nameLoader.classList.add( "netgis-hide" );
this.nameList.innerHTML = "";
if ( data.charAt( 0 ) !== '{' && data.charAt( 0 ) !== '[' ) return;
var json = JSON.parse( data );
for ( var i = 0; i < json.data.length; i++ )
{
var item = json.data[ i ];
var li = this.createNameItem( item[ "gmk_name" ] );
li.getElementsByTagName( "button" )[ 0 ].setAttribute( "data-id", item[ "gmk_gmn" ] );
this.nameList.appendChild( li );
}
};
netgis.SearchParcel.prototype.onNameItemClick = function( e )
{
var button = e.target;
var id = button.getAttribute( "data-id" );
this.nameInput.value = button.innerHTML;
this.nameList.innerHTML = "";
this.districtInput.value = id;
};
netgis.SearchParcel.prototype.selectFirstName = function()
{
var buttons = this.nameList.getElementsByTagName( "button" );
if ( buttons.length > 0 )
{
buttons[ 0 ].click();
}
};
netgis.SearchParcel.prototype.onParcelSearchClick = function( e )
{
this.requestParcel
(
this.districtInput.value.trim(),
this.fieldInput.value.trim(),
this.parcelInputA.value.trim(),
this.parcelInputB.value.trim()
);
};
netgis.SearchParcel.prototype.requestParcel = function( district, field, parcelA, parcelB )
{
//var url = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json";
var url = this.client.config.searchParcel.parcelURL;
url = netgis.util.replace( url, "{district}", district ? district : "" );
url = netgis.util.replace( url, "{field}", field ? field : "" );
url = netgis.util.replace( url, "{parcelA}", parcelA ? parcelA : "" );
url = netgis.util.replace( url, "{parcelB}", parcelB ? parcelB : "" );
//url = "/geoportal/client/proxy.php?" + url;
this.parcelTable.classList.add( "netgis-hide" );
this.parcelList.innerHTML = "";
this.parcelInfo.innerHTML = "Suche Flurstücke...";
netgis.util.request( url, this.onParcelResponse.bind( this ) );
};
netgis.SearchParcel.prototype.onParcelResponse = function( data )
{
var json = JSON.parse( data );
if ( json.count === 0 )
{
//TODO: if ( json.count === 0 ) -> json.Info
this.parcelInfo.innerHTML = json[ "Info" ];
}
else
{
this.parcelInfo.innerHTML = "Flurstücke gefunden: <span class='netgis-text-primary'>" + json[ "count" ] + "</span>";
for ( var i = 0; i < json.data.length; i++ )
{
var result = json.data[ i ];
var item = this.createParcelItem
(
result[ "fln" ],
result[ "fsn_zae" ],
result[ "fsn_nen" ],
result[ "fsk" ],
result[ "flaeche" ],
result[ "bbox" ],
result[ "geometry" ]
);
this.parcelList.appendChild( item );
}
this.parcelTable.classList.remove( "netgis-hide" );
}
this.parcelReset.classList.remove( "netgis-hide" );
if ( ! this.root.classList.contains( "netgis-hide" ) )
this.parcelTable.scrollIntoView();
};
netgis.SearchParcel.prototype.onParcelEnter = function( e )
{
var tr = e.target;
var geom = tr.getAttribute( "data-geom" );
this.client.invoke( netgis.Events.PARCEL_SHOW_PREVIEW, { geom: geom } );
};
netgis.SearchParcel.prototype.onParcelLeave = function( e )
{
this.client.invoke( netgis.Events.PARCEL_HIDE_PREVIEW, null );
};
netgis.SearchParcel.prototype.onParcelClick = function( e )
{
var tr = e.currentTarget;
var bbox = tr.getAttribute( "data-bbox" );
this.client.invoke( netgis.Events.MAP_ZOOM_WKT, bbox );
};
netgis.SearchParcel.prototype.onParcelImportClick = function( e )
{
var tr = e.currentTarget.parentElement.parentElement;
var geom = tr.getAttribute( "data-geom" );
this.client.invoke( netgis.Events.IMPORT_WKT, geom );
};
netgis.SearchParcel.prototype.onParcelResetClick = function( e )
{
this.reset();
};
netgis.SearchParcel.prototype.onSetMode = function( e )
{
if ( e === netgis.Modes.SEARCH_PARCEL && this.root.classList.contains( "netgis-hide" ) )
{
this.root.classList.remove( "netgis-hide" );
}
else
{
this.root.classList.add( "netgis-hide" );
}
};
netgis.SearchParcel.prototype.onLayerListToggle = function( e )
{
this.root.classList.add( "netgis-hide" );
};

View File

@ -14,6 +14,7 @@
.netgis-primary { background-color: #a7233f !important; color: white !important; }
.netgis-hover-primary:hover { background-color: #c82a4b !important; color: white !important; }
.netgis-light { background-color: #f4f4f4 !important; }
.netgis-hover-light:hover { background-color: #f4f4f4 !important; }
.netgis-text-primary { color: #a7233f !important; }
.netgis-hover-text-primary:hover { color: #c82a4b !important; }