当前位置: 首页>>代码示例>>Java>>正文


Java Literal类代码示例

本文整理汇总了Java中org.opengis.filter.expression.Literal的典型用法代码示例。如果您正苦于以下问题:Java Literal类的具体用法?Java Literal怎么用?Java Literal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Literal类属于org.opengis.filter.expression包,在下文中一共展示了Literal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitLiteralGeometry

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
protected void visitLiteralGeometry(Literal expression) throws IOException {
    // evaluate the literal and store it for later
    currentGeometry  = (Geometry) evaluateLiteral(expression, Geometry.class);

    if ( currentGeometry instanceof LinearRing ) {
        // convert LinearRing to LineString
        final GeometryFactory factory = currentGeometry.getFactory();
        final LinearRing linearRing = (LinearRing) currentGeometry;
        final CoordinateSequence coordinates;
        coordinates = linearRing.getCoordinateSequence();
        currentGeometry = factory.createLineString(coordinates);
    }

    final String geoJson = new GeometryJSON().toString(currentGeometry);
    currentShapeBuilder = mapReader.readValue(geoJson);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:FilterToElastic.java

示例2: getGraphicSize

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
/**
 * Gets a numeric value for the given graphic
 * 
 * @param feature sample to be used for evals
 * @param pointSymbolizer symbolizer
 * @param defaultSize size to use is none can be taken from the graphic
 */
private double getGraphicSize(Feature feature, Graphic graphic, int defaultSize) {
    if (graphic != null) {
        Expression sizeExp = graphic.getSize();
        if (sizeExp instanceof Literal) {
            Object size = sizeExp.evaluate(feature);
            if (size != null) {
                if (size instanceof Double) {
                    return (Double) size;
                }
                try {
                    return Double.parseDouble(size.toString());
                } catch (NumberFormatException e) {
                    return defaultSize;
                }

            }
        }
    }
    return defaultSize;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:28,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例3: getWidthSize

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
/**
 * Gets a numeric value for the given graphic
 * 
 * @param feature sample to be used for evals
 * @param pointSymbolizer symbolizer
 * @param defaultSize size to use is none can be taken from the graphic
 */
private double getWidthSize(Feature feature, Expression widthExp, int defaultSize) {
    if (widthExp != null) {
        if (widthExp instanceof Literal) {
            Object size = widthExp.evaluate(feature);
            if (size != null) {
                if (size instanceof Double) {
                    return (Double) size;
                }
                try {
                    return Double.parseDouble(size.toString());
                } catch (NumberFormatException e) {
                    return defaultSize;
                }
            }
        }
    }
    return defaultSize;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:26,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例4: createExpression

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
/**
 * Creates the expression.
 *
 * @param functionName the function name
 * @param argumentList the argument list
 * @return the expression
 */
/*
 * (non-Javadoc)
 * 
 * @see com.sldeditor.filter.v2.function.FunctionNameInterface#createExpression(org.opengis.filter.capability.FunctionName, java.util.List)
 */
@Override
public Expression createExpression(FunctionName functionName, List<Expression> argumentList) {
    if (functionName == null) {
        return null;
    }

    Literal fallback = null;
    Function function = functionFactory.function(functionName.getFunctionName(), argumentList,
            fallback);

    return function;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:25,代码来源:FunctionManager.java

示例5: visitDistanceSpatialOperator

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
protected void visitDistanceSpatialOperator(DistanceBufferOperator filter,
        PropertyName property, Literal geometry, boolean swapped,
        Object extraData) {

    property.accept(delegate, extraData);
    key = (String) delegate.field;
    geometry.accept(delegate, extraData);
    final Geometry geo = delegate.currentGeometry;
    lat = geo.getCentroid().getY();
    lon = geo.getCentroid().getX();
    final double inputDistance = filter.getDistance();
    final String inputUnits = filter.getDistanceUnits();
    distance = Double.valueOf(toMeters(inputDistance, inputUnits));

    delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL,
            "filter", ImmutableMap.of("geo_distance", 
                    ImmutableMap.of("distance", distance+SI.METER.toString(), key, ImmutableList.of(lon,lat)))));

    if ((filter instanceof DWithin && swapped)
            || (filter instanceof Beyond && !swapped)) {
        delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must_not", delegate.queryBuilder));
    }
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:24,代码来源:FilterToElasticHelper.java

示例6: clipToWorld

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
protected Literal clipToWorld(Literal geometry) {
    if(geometry != null) {
        Geometry g = geometry.evaluate(null, Geometry.class);
        if(g != null) {
            g.apply(new GeometryComponentFilter() {
                @Override
                public void filter(Geometry geom) {
                    geom.apply(new CoordinateFilter() {
                        @Override
                        public void filter(Coordinate coord) {
                            coord.setCoordinate(new Coordinate(clipLon(coord.x),clipLat(coord.y)));
                        }
                    });
                }
            });
            geometry = CommonFactoryFinder.getFilterFactory(null).literal(g);

        }
    }

    return geometry;
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:23,代码来源:FilterToElasticHelper.java

示例7: getLiteral

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
private static Literal getLiteral(Object o, AttributeType type) {
	Class<?> c = type.getBinding();
	Literal l = null;
	String s = o.toString();
	if (c == java.lang.Double.class)
		l = FF.literal(Double.parseDouble(s));
	else if (c == java.lang.Integer.class)
		l = FF.literal(Integer.parseInt(s));
	else if (c == java.lang.Long.class)
		l = FF.literal(Long.parseLong(s));
	else if (c == java.lang.Character.class)
		l = FF.literal(s.charAt(0));
	else if (c == java.lang.Boolean.class)
		l = FF.literal(Boolean.parseBoolean(s));
	else if (c == java.lang.Short.class)
		l = FF.literal(Short.parseShort(s));
	else if (c == java.lang.String.class)
		l = FF.literal(s);
	else
		l = FF.literal(o);
	return l;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:23,代码来源:GTUtils.java

示例8: utcTimeZone

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
private static void utcTimeZone() throws Exception{
	
	// utcTimeZone start
    Filter filter = ECQL.toFilter("2006-11-30T01:00:00+03:00 DURING 2006-11-30T00:30:00+03:00/2006-11-30T01:30:00+03:00 ");
	// utcTimeZone end
    Utility.prittyPrintFilter(filter);
    
    Boolean result = filter.evaluate(null);
    System.out.println("Result of filter evaluation: " + result);

    During during = (During) filter;
    Literal literal = (Literal)during.getExpression1();
    Date date = (Date)literal.getValue();
    
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
    TimeZone tz = TimeZone.getTimeZone("GMT+0300");
    sdf.setTimeZone(tz);
    System.out.println("Expression 1 as Date: " +sdf.format(date));
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:20,代码来源:ECQLExamples.java

示例9: visit

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
@Override
public void visit(DWithinCriterion criterion, Object context) {
	FilterContext fc = (FilterContext) context;
	String name = criterion.getAttributeName();
	if (name == null) {
		name = fc.getDefaultGeometryName();
	}
	Geometry geometry;
	try {
		geometry = converterService.toInternal(criterion.getValue());
		geometry = check(geometry);
		FilterFactory2 ff = (FilterFactory2) filterService.getFilterFactory();
		Expression nameExpression = ff.property(name);
		Literal geomLiteral = ff.literal(geometry);
		Filter filter = ff.dwithin(nameExpression, geomLiteral, criterion.getDistance(), criterion.getUnits());
		fc.setFilter(filter);
	} catch (GeomajasException e) {
		throw new IllegalArgumentException("Unparseable geometry in filter");
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:21,代码来源:DefaultCriterionFilterConverter.java

示例10: visitLiteralGeometry

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
@Override
protected void visitLiteralGeometry(Literal expression) throws IOException {
    // evaluate the literal and store it for later
    Geometry geom  = (Geometry) evaluateLiteral(expression, Geometry.class);
    
    if ( geom instanceof LinearRing ) {
        //postgis does not handle linear rings, convert to just a line string
        geom = geom.getFactory().createLineString(((LinearRing) geom).getCoordinateSequence());
    }
            
    out.write("GeomFromText('");
    out.write(geom.toText());
    if(currentSRID == null && currentGeometry  != null) {
        // if we don't know at all, use the srid of the geometry we're comparing against
        // (much slower since that has to be extracted record by record as opposed to 
        // being a constant)
        out.write("', SRID(\"" + currentGeometry.getLocalName() + "\"))");
    } else {
        out.write("', " + currentSRID + ")");
    }
    
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:23,代码来源:MonetDBFilterToSQL.java

示例11: visitBinarySpatialOperator

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
protected Object visitBinarySpatialOperator(BinarySpatialOperator filter,
        PropertyName property, Literal geometry, boolean swapped,
        Object extraData) {
    try {
        if (filter instanceof DistanceBufferOperator) {
            visitDistanceSpatialOperator((DistanceBufferOperator) filter,
                    property, geometry, swapped, extraData);
        } else {
            visitComparisonSpatialOperator(filter, property, geometry,
                    swapped, extraData);
        }
    } catch (IOException e) {
        throw new RuntimeException(IO_ERROR, e);
    }
    return extraData;
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:17,代码来源:FilterToSqlHelper.java

示例12: visitDistanceSpatialOperator

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
void visitDistanceSpatialOperator(DistanceBufferOperator filter,
        PropertyName property, Literal geometry, boolean swapped,
        Object extraData) throws IOException {
    if ((filter instanceof DWithin && !swapped)
            || (filter instanceof Beyond && swapped)) {
        out.write("ST_DWithin(");
        property.accept(delegate, extraData);
        out.write(",");
        geometry.accept(delegate, extraData);
        out.write(",");
        out.write(toMeters(filter.getDistance(), filter.getDistanceUnits()));
        out.write(")");
    }
    if ((filter instanceof DWithin && swapped)
            || (filter instanceof Beyond && !swapped)) {
        out.write("Distance(");
        property.accept(delegate, extraData);
        out.write(",");
        geometry.accept(delegate, extraData);
        out.write(") > ");
        out.write(Double.toString(filter.getDistance()));
    }
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:24,代码来源:FilterToSqlHelper.java

示例13: createRGBImageSymbol

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
/**
 * Creates the rgb image symbol.
 *
 * @param sym the sym
 * @param cov the cov
 * @param raster the raster
 */
private void createRGBImageSymbol(RasterSymbolizer sym, GridCoverage2D cov,
        WritableRaster raster) {
    double dest;
    List<Double> valueList = new ArrayList<Double>();

    GridEnvelope2D gridRange2D = cov.getGridGeometry().getGridRange2D();
    for (int x = 0; x < gridRange2D.getWidth(); x++) {
        for (int y = 0; y < gridRange2D.getHeight(); y++) {
            try {
                dest = raster.getSampleDouble(x, y, 0);

                if (!valueList.contains(dest)) {
                    valueList.add(dest);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    ColorMapImpl colourMap = new ColorMapImpl();

    // Sort the unique sample values in ascending order
    Collections.sort(valueList);

    // Create colour amp entries in the colour map for all the sample values
    for (Double value : valueList) {
        ColorMapEntry entry = new ColorMapEntryImpl();
        Literal colourExpression = ff
                .literal(ColourUtils.fromColour(ColourUtils.createRandomColour()));
        entry.setColor(colourExpression);
        entry.setQuantity(ff.literal(value.doubleValue()));

        colourMap.addColorMapEntry(entry);
    }

    colourMap.setType(ColorMap.TYPE_VALUES);
    sym.setColorMap(colourMap);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:47,代码来源:RasterReader.java

示例14: setSolidFill

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
/**
 * Sets the solid fill.
 *
 * @param fieldConfigManager the field config manager
 * @param expFillColour the exp fill colour
 * @param expFillColourOpacity the exp fill colour opacity
 */
public void setSolidFill(GraphicPanelFieldManager fieldConfigManager, Expression expFillColour,
        Expression expFillColourOpacity) {
    if (symbolTypeField != null) {
        FieldConfigBase field = fieldConfigManager.get(this.selectionComboBox);
        Literal expression = ff.literal(SOLID_FILL_VALUE);
        field.populate(expression);

        markerField.setSolidFill(fieldConfigManager, expFillColour, expFillColourOpacity);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:18,代码来源:SymbolTypeFactory.java

示例15: createExpression

import org.opengis.filter.expression.Literal; //导入依赖的package包/类
/**
 * Creates the expression.
 *
 * @param functionName the function name
 * @return the expression
 */
@Override
public Expression createExpression(FunctionName functionName) {
    if (functionName == null) {
        return null;
    }

    List<Expression> parameters = null;
    Literal fallback = null;
    Function function = functionFactory.function(functionName.getFunctionName(), parameters,
            fallback);

    return function;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:20,代码来源:FilterManager.java


注:本文中的org.opengis.filter.expression.Literal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。