On Tue, Dec 4, 2012 at 8:18 AM, Ian Turton <ijturton@...> wrote:
>
> On 3 December 2012 12:25, Fritz Richter <richter@...> wrote:
>
>> Hi everyone,
>> it is pretty stange. I'm playing with my setup for hours, and still can
>> not make it work.
>>
>> I'm trying to save a feature to my postgis database. Actually almost
>> everything is working, except the featureId, which is not used.
>>
>> Polygon polygon = GisUtils.convertToPolygon(tile);
>> //builder.set("tile_id", tileId);
>> builder.set("updated", new Date());
>> builder.set("geom", polygon);
>> ...
>> SimpleFeature feature = builder.buildFeature(featureId);
>>
>
> It looks possible that you meant tileId instead of featureId here - if
> featureId is null GeoTools will provide you with a default FID (which is
> what you are getting).
>
Use the provided fid is not a default behavior anyways, one has to set the
"use provided fid" hint in the feature use map to make it happen.
Here is an excerpt from the jdbc data store code:
boolean useExisting =
Boolean.TRUE.equals(feature.getUserData().get(Hints.USE_PROVIDED_FID));
if(useExisting) {
keyValues = decodeFID(key, feature.getID(), true);
} else if (!postInsert) {
keyValues = getNextValues( key, cx );
}
The reason for this is that data store concepts are based on the WFS
protocol,
which only had a notion of using the user provided fid in wfs 1.1, but was
dropped again in wfs 2.0 (and was not there in wfs 1.0).
So the default behavior is not to use it, you have to ask, and only a
handful
of stores do support this functionality (the jdbc ones do).
Cheers
Andrea
--
==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------
|