short type = expression.getType(); if ( target == Geometry.class && expression.getLiteral() instanceof Geometry ) { literal = expression.evaluate( null, target ); literal = expression.getLiteral().toString(); if ( encoding == null ) { encoding = expression.getLiteral().toString();
/** * Gets geometry. * * @param geometry The geometry from the filter. * * @throws IllegalFilterException If there are problems creating * expression. */ public void geometry(Geometry geometry) throws IllegalFilterException { // Sets the geometry for the expression, as appropriate LOGGER.finer("got geometry: " + geometry.toString()); //if(curExprssn.getType()==ExpressionDefault.LITERAL_GEOMETRY){ //LOGGER.finer("got geometry: "); curExprssn = ff.createLiteralExpression(); ((LiteralExpression) curExprssn).setLiteral(geometry); LOGGER.finer("set expression: " + curExprssn.toString()); currentState = "complete"; LOGGER.finer("set current state: " + currentState); // } }
/** * Converts a literal expression into a valid SDO object. Only handles * Literal Geometries, all other literals are passed up to the parent. * * @param literal The Literal expression to encode. * * @see org.geotools.filter.FilterVisitor#visit(org.geotools.filter.LiteralExpression) */ public void visit(LiteralExpression literal) { if (literal.getType() == DefaultExpression.LITERAL_GEOMETRY) { Geometry geometry = (Geometry) literal.getLiteral(); try { int srid = -1; Integer sridO = (Integer) srids.get(currentGeomColumnName); if (sridO == null) { // try for default sridO = (Integer) srids.get(null); } if (sridO != null) { srid = sridO.intValue(); } out.write(toSDOGeom(geometry, srid)); } catch (IOException e) { LOGGER.warning("IO Error exporting Literal Geometry"); } } else { // can't do it, send it off to the parent super.visit(literal); } }
public void visit(LiteralExpression expression) { LiteralExpression copy = null; try { copy = ff.createLiteralExpression(expression.getLiteral()); } catch (IllegalFilterException erp) { throw new RuntimeException(erp); } pages.push(copy); }
if (leftGeometry!=null && leftGeometry.getType() == ExpressionType.LITERAL_GEOMETRY) { le = (LiteralExpression) leftGeometry; if(le != null && le.getLiteral() != null && le.getLiteral() instanceof Geometry){ bbox = ((Geometry) le.getLiteral()).getEnvelopeInternal(); if(le != null && le.getLiteral() != null && le.getLiteral() instanceof Geometry){ Geometry g = (Geometry) le.getLiteral(); bbox = g.getEnvelopeInternal(); Envelope tmp = new Envelope(minx,maxx,miny,maxy); try { le.setLiteral((new GeometryFactory()).toGeometry(tmp)); } catch (IllegalFilterException e) { logger.warning(e.toString());
public int getClasses() { LiteralExpression classes = (LiteralExpression) getParameters().get(1); return ((Integer) classes.evaluate(null, Integer.class)).intValue(); }
/** * Checks to see if the literal is a geometry, and encodes it if it is, if * not just sends to the parent class. * * @param expression the expression to visit and encode. * * @throws RuntimeException for IO exception (need a better error) */ public void visit(LiteralExpression expression) throws RuntimeException { LOGGER.finer("exporting LiteralExpression"); try { if (expression.getType() == DefaultExpression.LITERAL_GEOMETRY) { visitLiteralGeometry(expression); } else { super.visit(expression); } } catch (java.io.IOException ioe) { LOGGER.warning("Unable to export expression" + ioe); throw new RuntimeException("io error while writing", ioe); } }
geomExpr.accept(this);
public void visit(org.geotools.filter.LiteralExpression expression) { Object value = expression.getLiteral(); if (Geometry.class.isAssignableFrom(value.getClass())) { geometryEncoder.encode( (Geometry) value ); } else { element("Literal",value.toString()); } }
/** * @see org.geotools.filter.FilterVisitor#visit(org.geotools.filter.LiteralExpression) */ public void visit(LiteralExpression expression) { if (expression.getType() == DefaultExpression.LITERAL_GEOMETRY) { Geometry bbox = (Geometry) expression.getLiteral(); if (this.bounds == null) { this.bounds = bbox.getEnvelopeInternal(); } else { this.bounds.expandToInclude(bbox.getEnvelopeInternal()); } } else { LOGGER.warning("LiteralExpression ignored!"); } }
if (leftGeometry!=null && leftGeometry.getType() == ExpressionType.LITERAL_GEOMETRY) { le = (LiteralExpression) leftGeometry; if(le != null && le.getLiteral() != null && le.getLiteral() instanceof Geometry){ bbox = ((Geometry) le.getLiteral()).getEnvelopeInternal(); if(le != null && le.getLiteral() != null && le.getLiteral() instanceof Geometry){ Geometry g = (Geometry) le.getLiteral(); bbox = g.getEnvelopeInternal(); Envelope tmp = new Envelope(minx,maxx,miny,maxy); try { le.setLiteral((new GeometryFactory()).toGeometry(tmp)); } catch (IllegalFilterException e) { logger.warning(e.toString());
public int getClasses() { LiteralExpression classes = (LiteralExpression) getParameters().get(1); return ((Integer) classes.evaluate(null, Integer.class)).intValue(); }
short type = expression.getType(); if ( target == Geometry.class && expression.getLiteral() instanceof Geometry ) { literal = expression.evaluate( null, target ); literal = expression.getLiteral().toString(); if ( encoding == null ) { encoding = expression.getLiteral().toString();
protected Envelope extractBboxForSpatialIndexQuery(GeometryFilter f) { GeometryFilter geomFilter = (GeometryFilter) f; Expression leftGeometry = geomFilter.getLeftGeometry(); Expression rightGeometry = geomFilter.getRightGeometry(); Geometry g; if( leftGeometry instanceof LiteralExpression ){ g=(Geometry) ((LiteralExpression) leftGeometry).getLiteral(); }else{ g=(Geometry) ((LiteralExpression) rightGeometry).getLiteral(); } return g.getEnvelopeInternal(); }
/** * Checks to see if the literal is a geometry, and encodes it if it is, if * not just sends to the parent class. * * @param expression * the expression to visit and encode. * * @throws IOException * for IO exception (need a better error) */ public void visitLiteralGeometry(LiteralExpression expression) throws IOException { Geometry bbox = (Geometry) expression.evaluate( null, Geometry.class ); String geomText = null; if ( bbox instanceof LinearRing ) { //postgis does not handle linear rings, convert to just a line string LineString lineString = new LineString( ((LinearRing)bbox).getCoordinateSequence(), bbox.getFactory() ); geomText = wkt.write( lineString ); } else { geomText = wkt.write(bbox); } out.write("GeometryFromText('" + geomText + "', " + srid + ")"); }
/** * Gets geometry. * * @param geometry The geometry from the filter. * * @throws IllegalFilterException If there are problems creating * expression. */ public void geometry(Geometry geometry) throws IllegalFilterException { // Sets the geometry for the expression, as appropriate LOGGER.finer("got geometry: " + geometry.toString()); //if(curExprssn.getType()==ExpressionDefault.LITERAL_GEOMETRY){ //LOGGER.finer("got geometry: "); curExprssn = ff.createLiteralExpression(); ((LiteralExpression) curExprssn).setLiteral(geometry); LOGGER.finer("set expression: " + curExprssn.toString()); currentState = "complete"; LOGGER.finer("set current state: " + currentState); // } }
length = Integer.parseInt(((LiteralExpression) cf.getRightValue()).getLiteral() .toString()); } else { if (cf.getRightValue() instanceof LengthFunction) { length = Integer.parseInt(((LiteralExpression) cf .getLeftValue()).getLiteral() .toString());
try { Object temp = new Integer(message); ((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete"; } catch (NumberFormatException nfe1) { try { Object temp = new Double(message); ((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete"; } catch (NumberFormatException nfe2) { Object temp = message; ((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete"; ((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete";
.getRightValue()).getLiteral().toString()); } else { if (cf.getRightValue() instanceof LengthFunction) { length = Integer .parseInt(((LiteralExpression) cf .getLeftValue()).getLiteral() .toString());
((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete"; } catch (NumberFormatException nfe1) { try { Object temp = new Double(message); ((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete"; } catch (NumberFormatException nfe2) { Object temp = message; ((LiteralExpression) curExprssn).setLiteral(temp); currentState = "complete";