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

3.3 bugfix featureinfo queryable #519

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static MapOptions parseLayerOptions( LayerOptionsType cfg ) {
Quality quali = null;
Interpolation interpol = null;
int maxFeats = -1;
int rad = 1;
int rad = -1;
try {
alias = Antialias.valueOf( cfg.getAntiAliasing() );
} catch ( Throwable e ) {
Expand All @@ -227,10 +227,14 @@ public static MapOptions parseLayerOptions( LayerOptionsType cfg ) {
if ( cfg.getMaxFeatures() != null ) {
maxFeats = cfg.getMaxFeatures();
}
if ( cfg.getFeatureInfo() != null && cfg.getFeatureInfo().isEnabled() ) {
rad = cfg.getFeatureInfo().getPixelRadius().intValue();
if ( cfg.getFeatureInfo() != null ) {
if ( cfg.getFeatureInfo().isEnabled() ) {
rad = Math.max( 0, cfg.getFeatureInfo().getPixelRadius().intValue() );
} else {
rad = 0;
}
} else if ( cfg.getFeatureInfoRadius() != null ) {
rad = cfg.getFeatureInfoRadius();
rad = Math.max( 0, cfg.getFeatureInfoRadius() );
}
return new MapOptions( quali, interpol, alias, maxFeats, rad );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,16 @@ public void setCascaded( int cascaded ) {
}

/**
* @return the queryable
* @return true if the layer can be queried
* @see MapOptions#getFeatureInfoRadius()
*/
public boolean isQueryable() {
if ( mapOptions == null ) {
return true;
}
return mapOptions.getFeatureInfoRadius() > 0;

//TRICKY assume that, the service is query able by default (<0)
return mapOptions.getFeatureInfoRadius() != 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
/**
*
* @author <a href="mailto:[email protected]">Andreas Schmitz</a>
* @author last edited by: $Author: stranger $
*
* @version $Revision: $, $Date: $
* @author <a href="mailto:[email protected]">Stephan Reichhelm</a>
*/
public class MapOptions {

Expand All @@ -60,7 +58,7 @@ public MapOptions( Quality quality, Interpolation interpol, Antialias antialias,
this.interpol = interpol;
this.antialias = antialias;
this.maxFeatures = maxFeatures;
this.setFeatureInfoRadius( featureInfoRadius );
this.featureInfoRadius = featureInfoRadius;
}

/**
Expand Down Expand Up @@ -124,15 +122,15 @@ public void setMaxFeatures( int maxFeatures ) {
}

/**
* @return the featureInfoRadius, a value < 1 means disabled
* @return the featureInfoRadius, a value < 1 means default, 0 means disabled and > 0 for the radius
*/
public int getFeatureInfoRadius() {
return featureInfoRadius;
}

/**
* @param featureInfoRadius
* the featureInfoRadius to set, a value < 1 means disabled
* the featureInfoRadius to set, a value < 1 means default, 0 means disabled and > 0 for the radius
*/
public void setFeatureInfoRadius( int featureInfoRadius ) {
this.featureInfoRadius = featureInfoRadius;
Expand Down Expand Up @@ -246,5 +244,4 @@ public Interpolation getOption( String layer ) {
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ private InterpolationType determineInterpolation( Interpolation fromRequest ) {
public CoverageLayerData infoQuery( LayerQuery query, List<String> headers )
throws OWSException {
try {
Envelope bbox = query.calcClickBox( query.getRenderingOptions().getFeatureInfoRadius( getMetadata().getName() ) );
int layerRadius = -1;
if ( getMetadata().getMapOptions() != null ) {
layerRadius = getMetadata().getMapOptions().getFeatureInfoRadius();
}
final Envelope bbox = query.calcClickBox( layerRadius > -1 ? layerRadius : query.getLayerRadius() );

RangeSet filter = dimensionHandler.getDimensionFilter( query.getDimensions(), headers );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ public FeatureLayerData infoQuery( final LayerQuery query, List<String> headers
filter = Filters.and( filter, getStyleFilters( style, query.getScale() ) );
filter = Filters.and( filter, query.getFilter() );

final Envelope clickBox = query.calcClickBox( query.getLayerRadius() );
int layerRadius = -1;
if ( getMetadata().getMapOptions() != null ) {
layerRadius = getMetadata().getMapOptions().getFeatureInfoRadius();
}
final Envelope clickBox = query.calcClickBox( layerRadius > -1 ? layerRadius : query.getLayerRadius() );

filter = (OperatorFilter) Filters.addBBoxConstraint( clickBox, filter, null );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ public FeatureCollection getFeatures( org.deegree.protocol.wms.ops.GetFeatureInf
|| l.getMetadata().getScaleDenominators().second < scale ) {
continue;
}

if (!l.getMetadata().isQueryable()) {
continue;
}

list.add( l.infoQuery( query, headers ) );
}
}
Expand Down Expand Up @@ -453,15 +458,7 @@ private List<LayerQuery> prepareGetFeatures( org.deegree.protocol.wms.ops.GetFea
LayerRef lr = layerItr.next();
StyleRef sr = styleItr.next();
OperatorFilter f = filterItr == null ? null : filterItr.next();
int layerRadius = 0;
for ( org.deegree.layer.Layer l : Themes.getAllLayers( themeMap.get( lr.getName() ) ) ) {
if ( l.getMetadata().getMapOptions() != null
&& l.getMetadata().getMapOptions().getFeatureInfoRadius() != 1 ) {
layerRadius = l.getMetadata().getMapOptions().getFeatureInfoRadius();
} else {
layerRadius = defaultLayerOptions.getFeatureInfoRadius();
}
}
final int layerRadius = defaultLayerOptions.getFeatureInfoRadius();
LayerQuery query = new LayerQuery( gfi.getEnvelope(), gfi.getWidth(), gfi.getHeight(), gfi.getX(),
gfi.getY(), gfi.getFeatureCount(), f, sr, gfi.getParameterMap(),
gfi.getDimensions(), new MapOptionsMaps(), gfi.getEnvelope(),
Expand Down Expand Up @@ -557,7 +554,7 @@ public Pair<Integer, Integer> getLegendSize( Style style ) {
return getLegendHandler.getLegendSize( style );
}

public BufferedImage getLegend( GetLegendGraphic req ) {
public BufferedImage getLegend( GetLegendGraphic req ) throws OWSException {
return getLegendHandler.getLegend( req );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Occam Labs UG (haftungsbeschränkt)
import org.deegree.layer.metadata.LayerMetadata;
import org.deegree.rendering.r2d.legends.Legends;
import org.deegree.services.wms.controller.WMSController;
import org.deegree.services.wms.controller.capabilities.theme.LayerMetadataQueryable;
import org.deegree.style.se.unevaluated.Style;
import org.deegree.theme.Theme;
import org.deegree.theme.Themes;
Expand Down Expand Up @@ -97,14 +98,17 @@ void writeTheme( XMLStreamWriter writer, Theme theme )
LayerMetadata md = theme.getMetadata();
// TODO think about a push approach instead of a pull approach
LayerMetadata lmd = null;
int layerQueryable = 0;
for ( org.deegree.layer.Layer l : Themes.getAllLayers( theme ) ) {
layerQueryable |= LayerMetadataQueryable.analyseQueryable( l.getMetadata() );
if ( lmd == null ) {
lmd = l.getMetadata();
} else {
lmd.merge( l.getMetadata() );
}
}
md.merge( lmd );
LayerMetadataQueryable.applyQueryable( md, layerQueryable );

if ( md.isQueryable() && md.getName() != null ) {
writer.writeAttribute( "queryable", "1" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Occam Labs UG (haftungsbeschränkt)
import org.deegree.rendering.r2d.legends.Legends;
import org.deegree.services.metadata.OWSMetadataProvider;
import org.deegree.services.wms.controller.WMSController;
import org.deegree.services.wms.controller.capabilities.theme.LayerMetadataQueryable;
import org.deegree.style.se.unevaluated.Style;
import org.deegree.theme.Theme;
import org.deegree.theme.Themes;
Expand Down Expand Up @@ -101,14 +102,17 @@ void writeTheme( XMLStreamWriter writer, Theme theme )
LayerMetadata md = theme.getMetadata();
// TODO think about a push approach instead of a pull approach
LayerMetadata lmd = null;
int layerQueryable = 0;
for ( org.deegree.layer.Layer l : Themes.getAllLayers( theme ) ) {
layerQueryable |= LayerMetadataQueryable.analyseQueryable( l.getMetadata() );
if ( lmd == null ) {
lmd = l.getMetadata();
} else {
lmd.merge( l.getMetadata() );
}
}
md.merge( lmd );
LayerMetadataQueryable.applyQueryable( md, layerQueryable );

writer.writeStartElement( WMSNS, "Layer" );

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2001-2015 by:
- Department of Geography, University of Bonn -
and
- lat/lon GmbH -
and
- grit graphische Informationstechnik Beratungsgesellschaft mbH -

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Contact information:

lat/lon GmbH
Aennchenstr. 19, 53177 Bonn
Germany
http://lat-lon.de/

Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/

grit graphische Informationstechnik Beratungsgesellschaft mbH
Landwehrstr. 143, 59368 Werne
Germany
http://www.grit.de/

e-mail: [email protected]
----------------------------------------------------------------------------*/
package org.deegree.services.wms.controller.capabilities.theme;

import org.deegree.layer.metadata.LayerMetadata;
import org.deegree.rendering.r2d.context.MapOptions;
import org.deegree.theme.Theme;

/**
* Merges {@link LayerMetadata} of {@link Theme} objects.
*
* @author <a href="mailto:[email protected]">Stephan Reichhelm</a>
*/
public class LayerMetadataQueryable {

private static final int QUERYABLE_DEFAULT_MASK = 1;

private static final int QUERYABLE_DISABLED_MASK = 2;

private static final int QUERYABLE_ENABLED_MASK = 4;

public static int analyseQueryable( LayerMetadata m ) {
if ( m.getMapOptions() == null )
return QUERYABLE_DEFAULT_MASK;

int r = m.getMapOptions().getFeatureInfoRadius();

if ( r < 0 )
return QUERYABLE_DEFAULT_MASK;
else if ( r == 0 )
return QUERYABLE_DISABLED_MASK;
else
return QUERYABLE_ENABLED_MASK;
}

public static void applyQueryable( LayerMetadata themeMetadata, int analyseResult ) {
if ( themeMetadata.getMapOptions() == null ) {
themeMetadata.setMapOptions( new MapOptions( null, null, null, -1, -1 ) );
}

if ( analyseResult == QUERYABLE_DISABLED_MASK ) {
themeMetadata.getMapOptions().setFeatureInfoRadius( 0 );
} else {
themeMetadata.getMapOptions().setFeatureInfoRadius( -1 );
}
}

}