[Geoserver-users] Custom FeatureType

Hello!

  I created a new FeatureType with Config/Data/FeatureType/New. The
FeatureType is a view in database postgres. And in my jsp I create a layer
with this featuretype
These are the sentences:

olayer = new OpenLayers.Layer.WMS( 'AR_3_13200',
'http://localhost:8080/geoserver/wms’, {layers: 'topp:Nodos_Sistema',
transparent:'true', styles: '', srs: 'EPSG:4326', tiled: 'true',}, {
'reprojected':true, 'isBaseLayer': false, 'opacity': 0.5 },{buffer: 0});

map.addLayer(olayer);

It' is ok!

Now, I want create a custom featuretype filtering 'topp:Nodos_Sistema' from
code.
For example:

'topp:Nodos_Sistema' is this view

CREATE OR REPLACE VIEW "Nodos_Sistema" AS
SELECT "EL_Nodos".sis_pais AS sis_tipo, "EL_Nodos".sis_codigo,
"EL_Nodos".cap_codigo, "EL_Nodos".nod_id, "EL_Nodos".nod_objeto,
"EL_Nodos".nod_descripcion, "EL_Nodos".oid
   FROM el_nodos "EL_Nodos"
  WHERE "EL_Nodos".sis_pais = 'SI';

I want create a freaturetype with

SELECT sis_tipo, sis_codigo, cap_codigo, nod_id, nod_objeto,
nod_descripcion,
       oid
  FROM "Nodos_Sistema"
Where sis_codigo = 1;

And other with

SELECT sis_tipo, sis_codigo, cap_codigo, nod_id, nod_objeto,
nod_descripcion,
       oid
  FROM "Nodos_Sistema"
Where sis_codigo = 3;

But this from my code, no by web Config/Data/FeatureType/New.

In the geoserver docs I find this, but I don`t like this way
      Alternatively, the FeatureType can be defined by manually creating a
directory ("localPostgis_test" in this example), with an info.xml file in
the featureTypes folder, which is itself located in Geoserver's data
directory. The catalog still needs to be reloaded, so the new FeatureType
is available.

Thank you

Regards

Abel
--
View this message in context: http://www.nabble.com/Custom-FeatureType-tp22789714p22789714.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

The recommended way to do add feature types programatically is via the REST configuration interfaces:

http://gridlock.openplans.org/geoserver/1.7.x/doc/user/extensions/rest/

However you will have to create all the views manually and manually create a geometry_columns entry for each view you want to publish as a feature type. Once you do that you should be able to just make a single rest call (see the examples from the above link) to register the feature type.

-Justin

abelq wrote:

Hello!

  I created a new FeatureType with Config/Data/FeatureType/New. The
FeatureType is a view in database postgres. And in my jsp I create a layer
with this featuretype
These are the sentences:

olayer = new OpenLayers.Layer.WMS( 'AR_3_13200',
'http://localhost:8080/geoserver/wms’, {layers: 'topp:Nodos_Sistema',
transparent:'true', styles: '', srs: 'EPSG:4326', tiled: 'true',}, {
'reprojected':true, 'isBaseLayer': false, 'opacity': 0.5 },{buffer: 0});

map.addLayer(olayer);

It' is ok!

Now, I want create a custom featuretype filtering 'topp:Nodos_Sistema' from
code.
For example:

'topp:Nodos_Sistema' is this view

CREATE OR REPLACE VIEW "Nodos_Sistema" AS SELECT "EL_Nodos".sis_pais AS sis_tipo, "EL_Nodos".sis_codigo,
"EL_Nodos".cap_codigo, "EL_Nodos".nod_id, "EL_Nodos".nod_objeto,
"EL_Nodos".nod_descripcion, "EL_Nodos".oid
   FROM el_nodos "EL_Nodos"
  WHERE "EL_Nodos".sis_pais = 'SI';

I want create a freaturetype with

SELECT sis_tipo, sis_codigo, cap_codigo, nod_id, nod_objeto,
nod_descripcion, oid
  FROM "Nodos_Sistema" Where sis_codigo = 1;

And other with

SELECT sis_tipo, sis_codigo, cap_codigo, nod_id, nod_objeto,
nod_descripcion, oid
  FROM "Nodos_Sistema" Where sis_codigo = 3;

But this from my code, no by web Config/Data/FeatureType/New.

In the geoserver docs I find this, but I don`t like this way
      Alternatively, the FeatureType can be defined by manually creating a
directory ("localPostgis_test" in this example), with an info.xml file in
the featureTypes folder, which is itself located in Geoserver's data
directory. The catalog still needs to be reloaded, so the new FeatureType
is available.

Thank you

Regards

Abel

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Justin

I used CQL_Filter

olayer = new OpenLayers.Layer.WMS( 'AR_3_13200',
'http://localhost:8080/geoserver/wms’, {CQL_Filter:'campo1=1&&campo2=1'.
'layers: 'topp:Nodos_Sistema', transparent:'true', styles: '', srs:
'EPSG:4326', tiled: 'true',}, { 'reprojected':true, 'isBaseLayer': false,
'opacity': 0.5 },{buffer: 0});

And It work.

I'll see your way.

Thank you

Justin Deoliveira-6 wrote:

The recommended way to do add feature types programatically is via the
REST configuration interfaces:

http://gridlock.openplans.org/geoserver/1.7.x/doc/user/extensions/rest/

However you will have to create all the views manually and manually
create a geometry_columns entry for each view you want to publish as a
feature type. Once you do that you should be able to just make a single
rest call (see the examples from the above link) to register the feature
type.

-Justin

abelq wrote:

Hello!

  I created a new FeatureType with Config/Data/FeatureType/New. The
FeatureType is a view in database postgres. And in my jsp I create a
layer
with this featuretype
These are the sentences:

olayer = new OpenLayers.Layer.WMS( 'AR_3_13200',
'http://localhost:8080/geoserver/wms’, {layers: 'topp:Nodos_Sistema',
transparent:'true', styles: '', srs: 'EPSG:4326', tiled: 'true',}, {
'reprojected':true, 'isBaseLayer': false, 'opacity': 0.5 },{buffer: 0});

map.addLayer(olayer);

It' is ok!

Now, I want create a custom featuretype filtering 'topp:Nodos_Sistema'
from
code.
For example:

'topp:Nodos_Sistema' is this view

CREATE OR REPLACE VIEW "Nodos_Sistema" AS
SELECT "EL_Nodos".sis_pais AS sis_tipo, "EL_Nodos".sis_codigo,
"EL_Nodos".cap_codigo, "EL_Nodos".nod_id, "EL_Nodos".nod_objeto,
"EL_Nodos".nod_descripcion, "EL_Nodos".oid
   FROM el_nodos "EL_Nodos"
  WHERE "EL_Nodos".sis_pais = 'SI';

I want create a freaturetype with

SELECT sis_tipo, sis_codigo, cap_codigo, nod_id, nod_objeto,
nod_descripcion,
       oid
  FROM "Nodos_Sistema"
Where sis_codigo = 1;

And other with

SELECT sis_tipo, sis_codigo, cap_codigo, nod_id, nod_objeto,
nod_descripcion,
       oid
  FROM "Nodos_Sistema"
Where sis_codigo = 3;

But this from my code, no by web Config/Data/FeatureType/New.

In the geoserver docs I find this, but I don`t like this way
      Alternatively, the FeatureType can be defined by manually creating
a
directory ("localPostgis_test" in this example), with an info.xml file
in
the featureTypes folder, which is itself located in Geoserver's data
directory. The catalog still needs to be reloaded, so the new
FeatureType
is available.

Thank you

Regards

Abel

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
View this message in context: http://www.nabble.com/Custom-FeatureType-tp22789714p22916870.html
Sent from the GeoServer - User mailing list archive at Nabble.com.