本文整理了Java中org.geotools.filter.Filters.asDouble()
方法的一些代码示例,展示了Filters.asDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filters.asDouble()
方法的具体详情如下:
包路径:org.geotools.filter.Filters
类名称:Filters
方法名:asDouble
[英]Obtain the provided Expression as a double.
[中]以双精度形式获取提供的表达式。
代码示例来源:origin: geotools/geotools
/**
* Retrieve the opacity value of an Expression.
*
* @param opacity Expression object
* @returna double value or 1.0 if unavailable.
*/
private static double opacity(Expression opacity) {
if (opacity == null) {
return 1.0;
}
double value = Filters.asDouble(opacity);
return (Double.isNaN(value) ? 1.0 : value);
}
代码示例来源:origin: geotools/geotools
/**
* Retrieves the opacity from a RasterSymbolizer.
*
* <p>If you are using something fun like rules you will need to do your own thing.
*
* @param symbolizer Raster symbolizer information.
* @return opacity of the first RasterSymbolizer or NaN if unavailable.
*/
public static double rasterOpacity(RasterSymbolizer symbolizer) {
if (symbolizer == null) {
return Double.NaN;
}
return Filters.asDouble(symbolizer.getOpacity());
}
代码示例来源:origin: geotools/geotools
/**
* Retrieve the opacity from the provided fill; or return the default.
*
* @param fill
* @return opacity from the above fill; or return the Fill.DEFAULT value
*/
public static double opacity(Fill fill) {
if (fill == null) {
fill = Fill.DEFAULT;
}
Expression opacityExp = fill.getOpacity();
if (opacityExp == null) {
opacityExp = Fill.DEFAULT.getOpacity();
}
return Filters.asDouble(opacityExp);
}
代码示例来源:origin: geotools/geotools
/**
* Retrieves the halo opacity from the first TextSymbolizer.
*
* @param symbolizer Text symbolizer information.
* @return double of the halo's opacity, or NaN if unavailable.
*/
public static double textHaloOpacity(TextSymbolizer symbolizer) {
if (symbolizer == null) {
return Double.NaN;
}
Halo halo = symbolizer.getHalo();
if (halo == null) {
return Double.NaN;
}
Fill fill = halo.getFill();
if (fill == null) {
return Double.NaN;
}
Expression expr = fill.getOpacity();
if (expr == null) {
return Double.NaN;
}
return Filters.asDouble(expr);
}
代码示例来源:origin: geotools/geotools
/**
* Retrieves the point border opacity from a PointSymbolizer.
*
* <p>If you are using something fun like rules you will need to do your own thing.
*
* @param symbolizer Point symbolizer information.
* @return double of the point's border opacity, or NaN if unavailable.
*/
public static double pointBorderOpacity(PointSymbolizer symbolizer) {
if (symbolizer == null) {
return Double.NaN;
}
Graphic graphic = symbolizer.getGraphic();
if (graphic == null) {
return Double.NaN;
}
for (GraphicalSymbol gs : graphic.graphicalSymbols()) {
if (gs != null && gs instanceof Mark) {
Mark mark = (Mark) gs;
Stroke stroke = mark.getStroke();
if (stroke != null) {
Expression exp = stroke.getOpacity();
return Filters.asDouble(exp);
}
}
}
return Double.NaN;
}
代码示例来源:origin: org.geotools/gt2-main
/**
* This method is here for backward compatability.
*
* @param expr DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @see Filters#doubleValue(Expression)
* @deprecated
*/
public static double doubleValue(Expression expr) {
return Filters.asDouble(expr);
}
代码示例来源:origin: org.geotools/gt-main
/**
* Retrieve the opacity value of an Expression.
*
* @param opacity Expression object
*
* @returna double value or 1.0 if unavailable.
*/
private static double opacity( Expression opacity ) {
if( opacity == null ){
return 1.0;
}
double value = Filters.asDouble(opacity);
return (Double.isNaN(value) ? 1.0 : value);
}
代码示例来源:origin: org.geotools/gt-main
/**
* Retrieves the opacity from a RasterSymbolizer.
* <p>
* If you are using something fun like rules you will need to do your own
* thing.
* </p>
*
* @param symbolizer Raster symbolizer information.
* @return opacity of the first RasterSymbolizer or NaN if unavailable.
*/
public static double rasterOpacity(RasterSymbolizer symbolizer) {
if (symbolizer == null) {
return Double.NaN;
}
return Filters.asDouble(symbolizer.getOpacity());
}
代码示例来源:origin: org.geotools/gt-main
/**
* Retrieve the opacity from the provided fill; or return the default.
* @param fill
* @return opacity from the above fill; or return the Fill.DEFAULT value
*/
public static double opacity(Fill fill) {
if (fill == null) {
fill = Fill.DEFAULT;
}
Expression opacityExp = fill.getOpacity();
if( opacityExp == null ){
opacityExp = Fill.DEFAULT.getOpacity();
}
return Filters.asDouble(opacityExp);
}
代码示例来源:origin: org.geotools/gt-widgets-swing-pending
valeur = Filters.asDouble(sym.getFill().getOpacity());
} else if (value instanceof PointSymbolizer) {
PointSymbolizer sym = (PointSymbolizer) value;
valeur = Filters.asDouble(sym.getGraphic().getOpacity());
} else if (value instanceof LineSymbolizer) {
LineSymbolizer sym = (LineSymbolizer) value;
valeur = Filters.asDouble(sym.getStroke().getOpacity());
} else if (value instanceof RasterSymbolizer) {
RasterSymbolizer sym = (RasterSymbolizer) value;
valeur = Filters.asDouble(sym.getOpacity());
代码示例来源:origin: geotools/geotools
assertEquals(0.5, Filters.asDouble(place.getAnchorPoint().getAnchorPointX()), 0.1);
assertEquals(0.5, Filters.asDouble(place.getAnchorPoint().getAnchorPointY()), 0.1);
代码示例来源:origin: geotools/geotools
assertEquals(0.5, Filters.asDouble(placement.getAnchorPoint().getAnchorPointX()), 0.1);
assertEquals(0.0, Filters.asDouble(placement.getAnchorPoint().getAnchorPointY()), 0.1);
assertEquals(0, Filters.asInt(placement.getDisplacement().getDisplacementX()));
assertEquals(5, Filters.asInt(placement.getDisplacement().getDisplacementY()));
代码示例来源:origin: org.geotools/gt-main
/**
* Retrieves the halo opacity from the first TextSymbolizer.
*
* @param symbolizer Text symbolizer information.
*
* @return double of the halo's opacity, or NaN if unavailable.
*/
public static double textHaloOpacity(TextSymbolizer symbolizer) {
if (symbolizer == null) {
return Double.NaN;
}
Halo halo = symbolizer.getHalo();
if (halo == null) {
return Double.NaN;
}
Fill fill = halo.getFill();
if (fill == null) {
return Double.NaN;
}
Expression expr = fill.getOpacity();
if( expr == null ){
return Double.NaN;
}
return Filters.asDouble(expr);
}
代码示例来源:origin: geotools/geotools
assertEquals(0.5, Filters.asDouble(placement.getAnchorPoint().getAnchorPointX()), 0.1);
assertEquals(0.0, Filters.asDouble(placement.getAnchorPoint().getAnchorPointY()), 0.1);
assertEquals(0, Filters.asInt(placement.getDisplacement().getDisplacementX()));
assertEquals(25, Filters.asInt(placement.getDisplacement().getDisplacementY()));
代码示例来源:origin: geotools/geotools
@Test
public void testRasterWithTransparentGradient() throws Exception {
// <UserStyle>
// <Title>SLD Cook Book: Transparent gradient</Title>
// <FeatureTypeStyle>
// <Rule>
// <RasterSymbolizer>
// <Opacity>0.3</Opacity>
// <ColorMap>
// <ColorMapEntry color="#008000" quantity="70" />
// <ColorMapEntry color="#663333" quantity="256" />
// </ColorMap>
// </RasterSymbolizer>
// </Rule>
// </FeatureTypeStyle>
// </UserStyle>
Style style = parse("raster", "transparent-gradient.sld");
RasterSymbolizer raster = SLD.rasterSymbolizer(style);
assertEquals(0.3, Filters.asDouble(raster.getOpacity()), 0.1);
ColorMapEntry e = raster.getColorMap().getColorMapEntry(0);
assertEquals("#008000", Filters.asString(e.getColor()));
assertEquals(70, Filters.asInt(e.getQuantity()));
e = raster.getColorMap().getColorMapEntry(1);
assertEquals("#663333", Filters.asString(e.getColor()));
assertEquals(256, Filters.asInt(e.getQuantity()));
}
代码示例来源:origin: org.geotools/gt-widgets-swing-pending
private Double format(MapLayer layer) {
FeatureTypeStyle[] sty = layer.getStyle().getFeatureTypeStyles();
double valeur = 1d;
Rule[] rules = sty[0].getRules();
for (int i = 0; i < rules.length; i++) {
Rule r = rules[i];
//on regarde si la regle s'applique au maplayer (s'il n'y a aucun filtre)
if (r.getFilter() == null) {
Symbolizer[] symbolizers = r.getSymbolizers();
for (int j = 0; j < symbolizers.length; j++) {
if (symbolizers[j] instanceof PolygonSymbolizer) {
PolygonSymbolizer sym = (PolygonSymbolizer) symbolizers[j];
valeur = Filters.asDouble(sym.getFill().getOpacity());
} else if (symbolizers[j] instanceof PointSymbolizer) {
PointSymbolizer sym = (PointSymbolizer) symbolizers[j];
//valeur = SLD.pointOpacity(sym);
valeur = Filters.asDouble(sym.getGraphic().getOpacity());
} else if (symbolizers[j] instanceof LineSymbolizer) {
LineSymbolizer sym = (LineSymbolizer) symbolizers[j];
valeur = Filters.asDouble(sym.getStroke().getOpacity());
} else if (symbolizers[j] instanceof RasterSymbolizer) {
RasterSymbolizer sym = (RasterSymbolizer) symbolizers[j];
valeur = Filters.asDouble(sym.getOpacity());
}
}
}
}
return valeur;
}
代码示例来源:origin: geotools/geotools
assertEquals(7.5, Filters.asDouble(stroke.getDashOffset()), 0.1);
代码示例来源:origin: geotools/geotools
assertEquals(0.5, Filters.asDouble(contrast.getGammaValue()), 0.1);
assertEquals(ContrastMethod.NORMALIZE, contrast.getMethod());
代码示例来源:origin: org.geotools/gt-main
/**
* Retrieves the point border opacity from a PointSymbolizer.
* <p>
* If you are using something fun like rules you will need to do your own
* thing.
*
* @param symbolizer Point symbolizer information.
*
* @return double of the point's border opacity, or NaN if unavailable.
*/
public static double pointBorderOpacity(PointSymbolizer symbolizer) {
if (symbolizer == null) {
return Double.NaN;
}
Graphic graphic = symbolizer.getGraphic();
if (graphic == null) {
return Double.NaN;
}
for (GraphicalSymbol gs : graphic.graphicalSymbols()) {
if (gs != null && gs instanceof Mark) {
Mark mark = (Mark) gs;
Stroke stroke = mark.getStroke();
if (stroke != null) {
Expression exp = stroke.getOpacity();
return Filters.asDouble(exp);
}
}
}
return Double.NaN;
}
内容来源于网络,如有侵权,请联系作者删除!