On Thu, Aug 29, 2013 at 7:27 PM, Bessette-Halsema, Dominique E <
dominique.besse...@gdit.com> wrote:
> I’m creating a wps and I was wondering how I get a feature by a featureid
> within geoserver..****
>
> ** **
>
> I would like
> https://localhost:8443/geoserver/gis/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=gis:simpleafeature&featureId=43601
> but using the geoserver classes.****
>
> ** **
>
> *public* *static* *void* GetFeature(String name, String namespace,
> String fid){****
>
> GeoServer geoServer = GeoServerExtensions.*bean*(GeoServer.*class*
> );****
>
> DefaultWebFeatureService20 wfs =
> *new*DefaultWebFeatureService20(geoServer);
> ****
>
> WFSInfo wfsinfo = wfs.getServiceInfo();****
>
> Catalog catalog = wfs.getCatalog();****
>
> *FeatureTypeInfo* featuretype =
> catalog.getFeatureTypeByName(namespace, name);****
>
> ** **
>
> //now what****
>
> }
>
You're going too much the long way. Get the Catalog bean, then do something
like
(almost pseudo code, totally untested):
FeatureTypeInfo info = catalog.getFeatureTypeByName(<theLayerName>);
SimpleFeatureSource fs = info.getFeatureSource();
FilterFactory ff = CommonFActoryFinder.getFilterFactory();
SimpleFeatureCollect coll = fs.getFeatures(ff.id(ff.featureId(<yourId));
SimpleFeatureIterator fi = null;
SimpleFeature theFeature = null;
try {
fi = coll.features();
theFeature = fi.next();
} finally {
fi.close();
}
Hope this helps
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
-------------------------------------------------------
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users