Greetings, Gabriel,
Ok, I'll try to make this change as soon as I get my hands on latest
geotools sources. But I really can't get how this simple
type-detection algorithm can lead to attribute values "shifting".
Here are two lines of interest from previously posted text-file (it
is somewhat large so I choose to send it as attachment):
101656 [FINEST] org.geotools.renderer.lite.LiteRenderer2 - ... done:
Feature[ id=t_plan_shp.2 , CODE=2 , the_geom=MULTIPOLYGON (((-41355708
-135367696, -41473280 -135213408, -41758912 -135070864, -41814588
-134997808, -41473028 -134738576, -40920272 -135035888, -41355708
-135367696))) , AREA=2.718921E11 , PERIMETER=2208942.0 , CITY_=3 , CITY_ID=374 ]
and
186547 [FINEST] org.geotools.renderer.lite.LiteRenderer2 - ... done:
Feature[ id=t_plan.1 , area=2.0 , perimeter=2.718921E11 , city_=2208942 ,
city_id=3 , code=374 , the_geom=MULTIPOLYGON (((-41355708 -135367696,
-41473280 -135213408, -41758912 -135070864, -41814588 -134997808, -41473028
-134738576, -40920272 -135035888, -41355708 -135367696))) ]
First "line" is part of rendering feature #2 from shape-file, second -
the same feature from PostGIS.
Stripped and compiled into table that will look like this:
area perimeter city_ city_id code
shp | 2.718921E11 | 2208942.0 | 3 | 374 | 2 |
postgis | 2.0 | 2.718921E11 | 2208942 | 3 | 374 |
So in the second case there is no single correct attribute value,
(they are shifted one position to the right) though when I look at the
PostgreSQL table itself all values are in place.
I also should note that layers, which have textual attributes does
not render at all, leaving following log trace for each feature:
6069484 [SEVERE] org.geotools.renderer.lite.LiteRenderer2$DefaultRenderListener
- expected java.lang.Double , but got java.lang.String
Most probably this is caused by the same displacement of attribute
columns. All this looks somewhat strange
But I still try to make the changes you advised and then tell the
results.
WBR,
Artie
I may guess at the answer, the Filter parsing code tends to 'try' to
parse anything it can as a number. I suspect that your 'code' is
trying to be compare a number with a string for equality.
This is a known, if annoying problem, that I made an effort of at fixing
for the xml parser.
I guess you mean
org.geotools.filter.ExpressionSAXParser::message(String)?
If so, yeah, this is an old bug I came around by just avoiding trying to
guess the literal type and passing the plain string. This is done for a
project I'm working on and is in a gt2.0 version I retrofited to work on
JDK 1.3
for instance, in the above mentioned method:
if (curExprssn instanceof AttributeExpression) {
...
} else if (curExprssn instanceof LiteralExpression) {
((LiteralExpression) curExprssn).setLiteral(message);
}
/* It was:
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";
}
}*/
I guess this is the right way since once the expression is evaluated it
would be the responsability of AttributeType.parse to get the
actual literal instance.
May be you can just try this modification and got it solved.
Best regards,
Gabriel.