[Geoserver-users] getFeature within geoserver

2013-08-29 Thread Bessette-Halsema, Dominique E
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=4360
1  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

}

 

Thanks

 

 



smime.p7s
Description: S/MIME cryptographic signature
--
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


Re: [Geoserver-users] getFeature within geoserver

2013-08-30 Thread Andrea Aime
Yep, that's it. I believe you can get to the catalog quicker this way:

On Thu, Aug 29, 2013 at 11:33 PM, Bessette-Halsema, Dominique E <
dominique.besse...@gdit.com> wrote:

> That worked thanks!
>
> ** **
>
> *public* *static* SimpleFeature GetFeature(String featurename, String
> namespace, String fid){
>
> SimpleFeature feature = *null*;
>
> GeoServer geoServer = GeoServerExtensions.*bean*(GeoServer.*class*
> );
>
> DefaultWebFeatureService20 wfs = 
> *new*DefaultWebFeatureService20(geoServer);
> 
>
> Catalog catalog = wfs.getCatalog();
>

Catalog catalog = GeoServerExtensions.bean("catalog");

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


Re: [Geoserver-users] getFeature within geoserver

2013-08-29 Thread Andrea Aime
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();
SimpleFeatureSource fs = info.getFeatureSource();
FilterFactory ff = CommonFActoryFinder.getFilterFactory();
SimpleFeatureCollect coll = fs.getFeatures(ff.id(ff.featureId(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


Re: [Geoserver-users] getFeature within geoserver

2013-08-29 Thread Bessette-Halsema, Dominique E
That worked thanks!

 

public static SimpleFeature GetFeature(String featurename, String namespace,
String fid){

SimpleFeature feature = null;

GeoServer geoServer = GeoServerExtensions.bean(GeoServer.class);

DefaultWebFeatureService20 wfs = new
DefaultWebFeatureService20(geoServer);

Catalog catalog = wfs.getCatalog();

FeatureTypeInfo info = catalog.getFeatureTypeByName(namespace,
featurename);

try{

SimpleFeatureSource fs = (SimpleFeatureSource)
info.getFeatureSource(null, null);

FilterFactory ff = CommonFactoryFinder.getFilterFactory();

Id id = ff.id(Collections.singleton(ff.featureId(fid)));

SimpleFeatureCollection coll = fs.getFeatures(id);

SimpleFeatureIterator fi = null;

try {

fi = coll.features();

feature = fi.next(); 

} finally {

   fi.close();

}

}

catch(Exception e){

LOGGER.info(e.getMessage());

}

 

return feature;

}

 

Dominique Bessette

Engineer, Software

General Dynamics Information Technology

Supporting Fleet Numerical Meteorology and Oceanography Center (FNMOC)

Office: 619-881-2748

 

 

From: andrea.a...@gmail.com [mailto:andrea.a...@gmail.com] On Behalf Of
Andrea Aime
Sent: Thursday, August 29, 2013 11:07 AM
To: Bessette-Halsema, Dominique E
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] getFeature within geoserver

 

On Thu, Aug 29, 2013 at 7:27 PM, Bessette-Halsema, Dominique E
 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
<https://localhost:8443/geoserver/gis/ows?service=WFS&version=1.0.0&request=
GetFeature&typeName=gis:simpleafeature&featureId=43601>
&version=1.0.0&request=GetFeature&typeName=gis:simpleafeature&featureId=4360
1  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();

SimpleFeatureSource fs = info.getFeatureSource();

FilterFactory ff = CommonFActoryFinder.getFilterFactory();

SimpleFeatureCollect coll = fs.getFeatures(ff.id(ff.featureId(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

 

---



smime.p7s
Description: S/MIME cryptographic signature
--
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