[Geoserver-users] WFS GetFeature JSON output does not include typename info

Hey there, how are you guys doing?

I was playing around with WFS GetFeature requests of the sort:
http://demo.opengeo.org/geoserver/wfs?service=WFS&REQUEST=GetFeature&TYPENAME=topp:states&bbox=32,-84,33,-83

With regular GML output, a full description of each selected feature is given, including its typename (in this case, "topp:states"). However, if we specify OUTPUTFORMAT=JSON, then we receive a nice JSON description of the feature, but no typename information! The selected feature does indeed have a "type" attribute, but it says "Feature":

Request:
http://demo.opengeo.org/geoserver/wfs?service=WFS&REQUEST=GetFeature&TYPENAME=topp:states&bbox=32,-84,33,-83&OUTPUTFORMAT=json

Response:
{
  "type":"FeatureCollection",
  "features":[
{"type":"Feature","id":"states.19","properties":{"STATE_NAME":"Georgia",...},"geometry":{...},"geometry_name":"the_geom"}
  ],
  "crs":{"type":"EPSG","properties":{"code":"4326"}},
  "bbox":[30.361057000000002,-85.608994,35.000277999999994,-80.89492]}
}

Is there a reason for this lack of information? (by the way, is there a spec as to how WFS servers should give JSON output?)
I ask this because, if I include 2 layers in the request (e.g., "TYPENAME=topp:states,topp:world"), then how will I know the typename of each feature in the response? In this case, we would have:

Request:
http://demo.opengeo.org/geoserver/wfs?service=WFS&REQUEST=GetFeature&TYPENAME=topp:states,topp:world&bbox=32,-84,33,-83&OUTPUTFORMAT=json

Response:
{
  "type":"FeatureCollection",
  "features":[
{"type":"Feature","id":"states.19","properties":{"STATE_NAME":"Georgia",...},"geometry":{...},"geometry_name":"the_geom"},
{"type":"Feature","id":"world.209","properties":{"FIPS":"US",...},"geometry":{...},"geometry_name":"the_geom"}
  ]
  "crs":{"type":"EPSG","properties":{"code":"4326"}},
  "bbox":[18.923882000000106, -179.14199799999994, 71.36581400000006, 179.77746600000012]
}

Cheers
Milton

--

Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502

On Thu, Feb 21, 2013 at 8:19 PM, Milton Jonathan <milton@anonymised.com> wrote:

Hey there, how are you guys doing?

I was playing around with WFS GetFeature requests of the sort:
http://demo.opengeo.org/geoserver/wfs?service=WFS&REQUEST=GetFeature&TYPENAME=topp:states&bbox=32,-84,33,-83

With regular GML output, a full description of each selected feature is
given, including its typename (in this case, “topp:states”). However, if
we specify OUTPUTFORMAT=JSON, then we receive a nice JSON description of
the feature, but no typename information! The selected feature does
indeed have a “type” attribute, but it says “Feature”:

The GeoJSON specification is here, and has no typename:
http://www.geojson.org/geojson-spec.html

OGC still does not recognize GeoJSON as a valid spec (you may notice no OGC standard
uses it) so there are no guidelines about using it with WFS or any other service.

That said, JSON is not based on schemas, so theoretically we would be free to add an extra attribute
for the type name.

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


I see…

But I’m a little surprised that nobody has ever raised this issue before. In other words: am I misusing WFS, trying to push it too far off the standard?

Thanks
Milton

···

On 22/02/2013 10:28, Andrea Aime wrote:

On Thu, Feb 21, 2013 at 8:19 PM, Milton Jonathan <milton@anonymised.com> wrote:

Hey there, how are you guys doing?

I was playing around with WFS GetFeature requests of the sort:
http://demo.opengeo.org/geoserver/wfs?service=WFS&REQUEST=GetFeature&TYPENAME=topp:states&bbox=32,-84,33,-83

With regular GML output, a full description of each selected feature is
given, including its typename (in this case, “topp:states”). However, if
we specify OUTPUTFORMAT=JSON, then we receive a nice JSON description of
the feature, but no typename information! The selected feature does
indeed have a “type” attribute, but it says “Feature”:

The GeoJSON specification is here, and has no typename:
http://www.geojson.org/geojson-spec.html

OGC still does not recognize GeoJSON as a valid spec (you may notice no OGC standard
uses it) so there are no guidelines about using it with WFS or any other service.

That said, JSON is not based on schemas, so theoretically we would be free to add an extra attribute
for the type name.

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


-- 

Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502

On Fri, Feb 22, 2013 at 5:50 PM, Milton Jonathan <milton@anonymised.com> wrote:

I see…

But I’m a little surprised that nobody has ever raised this issue before. In other words: am I misusing WFS, trying to push it too far off the standard?

It’s just that normally you ask for a single feature type, so the caller already knows the feature type.
I guess you have the issue because you’re making a query for multiple feature types.

I don’t believe you’re too far off, but you’re definitely off: the only standard output format for WFS is GML

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


Well ok.

Taking a look at the code, do you think it’s valid to simply add a “typename” in GeoJSONOutputFormat.write()? Doesn’t look complicated…

Milton

···

On 22/02/2013 14:06, Andrea Aime wrote:

On Fri, Feb 22, 2013 at 5:50 PM, Milton Jonathan <milton@anonymised.com> wrote:

I see…

But I’m a little surprised that nobody has ever raised this issue before. In other words: am I misusing WFS, trying to push it too far off the standard?

It’s just that normally you ask for a single feature type, so the caller already knows the feature type.
I guess you have the issue because you’re making a query for multiple feature types.

I don’t believe you’re too far off, but you’re definitely off: the only standard output format for WFS is GML

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


-- 

Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502

Hi,

I have a map that runs slow. I am trying to find out the problem.

Environment: GeoServer version is 2.2.3, SQL Server 2008, Tomcat 6.0, JDK 6.

The map has one layer using SQL view. The query runs very fast in SQL server 2008 console (less than a second), but it takes about a minute to load the map on web page.

As below is the log using GeoTools_Developer_Logging.

I see that it took about 10 second from getting service info to write out JPEG image.

It seems it took very long to write out the image which can’t be captured in the log.

How to speed up running the query from GeoServer? I set up spatial index in the database tale. How can I tell if spatial index is being used in GeoServer?

How to speed up writing out the image?

Thanks!
Meichun

Log details:

2013-02-22 12:14:10,101 INFO [org.geoserver.wms] -
Request: getServiceInfo
2013-02-22 12:14:10,101 DEBUG [org.geotools.styling] - number of fts set 1
2013-02-22 12:14:10,101 DEBUG [org.geotools.jdbc] - CREATE CONNECTION
2013-02-22 12:14:10,116 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
2013-02-22 12:14:10,116 DEBUG [org.geotools.jdbc] - CREATE CONNECTION
2013-02-22 12:14:10,132 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
2013-02-22 12:14:10,132 DEBUG [org.geotools.jdbc] - CREATE CONNECTION
2013-02-22 12:14:10,132 DEBUG [org.geotools.jdbc] - Gathering sql view result structure: select * from (Select * from fnEdCountByZip_GIS_Test
(
‘’
,‘’
,‘’
,‘’
,‘’
,‘’
)) as “vtable” where 1 = 0
2013-02-22 12:14:10,132 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
2013-02-22 12:14:10,132 DEBUG [org.geotools.jdbc] - CREATE CONNECTION
2013-02-22 12:14:10,148 DEBUG [org.geotools.jdbc] - Gathering sql view result structure: select * from (Select * from fnEdCountByZip_GIS_Test
(
‘’
,‘’
,‘’
,‘’
,‘’
,‘’
)) as “vtable” where 1 = 0
2013-02-22 12:14:10,148 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
2013-02-22 12:14:10,148 DEBUG [org.geotools.rendering] - Computed scale denominator: 3441158.722425866
2013-02-22 12:14:10,148 DEBUG [org.geotools.rendering] - Processing 1 stylers for http://www.ncdetect.org/gis/test:EDSyndromeCountByZip
2013-02-22 12:14:10,148 DEBUG [org.geotools.rendering] - creating rules for scale denominator - 3,441,158.722
2013-02-22 12:14:10,148 DEBUG [org.geotools.styling] - creating defaultMark
2013-02-22 12:14:10,148 DEBUG [org.geotools.styling] - creating defaultMark
2013-02-22 12:14:10,148 TRACE [org.geotools.styling] - ENTRY
2013-02-22 12:14:10,148 DEBUG [org.geotools.styling] - creating defaultMark
2013-02-22 12:14:10,148 DEBUG [org.geotools.rendering] - Expanding rendering area by 11 pixels to consider stroke width
2013-02-22 12:14:10,148 DEBUG [org.geotools.rendering] - Querying layer http://www.ncdetect.org/gis/test:EDSyndromeCountByZip with bbox: ReferencedEnvelope[-84.59019013308644 : -75.19033089137956, 33.6907547413986 : 36.7374862819874]
2013-02-22 12:14:10,148 DEBUG [org.geotools.jdbc] - CREATE CONNECTION
2013-02-22 12:14:10,148 TRACE [org.geotools.core] - ENTRY 4
2013-02-22 12:14:10,148 DEBUG [org.geotools.filter] - exporting PropertyName
2013-02-22 12:14:10,148 DEBUG [org.geotools.filter] - exporting LiteralExpression
2013-02-22 12:14:10,148 DEBUG [org.geotools.jdbc] - SELECT “ID”,“Count”,“GEOM”.STAsBinary() as “GEOM” FROM (Select * from fnEdCountByZip_GIS_Test
(
‘02/12/2013’
,‘02/21/2013’
,‘3’
,‘1 2 3 4 5 6 7 8 9 10’
,‘’
,‘county’
)) as “vtable” WHERE “GEOM”.Filter(geometry::STGeomFromText(‘POLYGON ((-84.59019013308644 33.6907547413986, -84.59019013308644 36.7374862819874, -75.19033089137956 36.7374862819874, -75.19033089137956 33.6907547413986, -84.59019013308644 33.6907547413986))’, 4326)) = 1
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - trying to render symbol circle
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - rendering mark @ PointRenderer circle
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - fetching mark of name circle
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - returning circle
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - creating text style
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - geomName = null
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - label is 3
2013-02-22 12:14:21,156 DEBUG [org.geotools.rendering] - setting pointPlacement
2013-02-22 12:14:21,172 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
2013-02-22 12:14:21,187 DEBUG [org.geotools.rendering] - Style cache hit ratio: 0.9953051643192489 , hits 212, requests 213
2013-02-22 12:14:21,187 INFO [org.geoserver.wms] -
Request: getMap
Time =
Filter = null
Format = image/jpeg
Buffer = 0
Height = 330
Width = 1064
Tiled = false
Palette = null
SRS = EPSG:4326
FeatureVersion = null
Legend = false
Styles = [StyleImpl[ name=circle_syndrome_count]]
Layers = [org.geoserver.wms.MapLayerInfo@anonymised.com]
MaxFeatures = null
Bbox = ReferencedEnvelope[-84.494979772443 : -75.285541252023, 33.785965102042 : 36.642275921344]
RemoteOwsType = null
RemoteOwsURL = null
Env = {}
FormatOptions = {}
Angle = 0.0
CQLFilter = null
Elevation =
FeatureId = null
StartIndex = null
ViewParams = [{EDATE=02/21/2013, LOCATIONID=, AGEGROUPID=1 2 3 4 5 6 7 8 9 10, BDATE=02/12/2013, SYNDROMEID=3, LOCATIONTYPE=county}]
Crs = GEOGCS[“WGS 84”,
DATUM[“World Geodetic System 1984”,
SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”, 0.017453292519943295],
AXIS[“Geodetic longitude”, EAST],
AXIS[“Geodetic latitude”, NORTH],
AUTHORITY[“EPSG”,“4326”]]
BgColor = java.awt.Color[r=255,g=255,b=255]
Transparent = false
SldBody = null
ValidateSchema = false
Sld = null
SldVersion = null
TilesOrigin = null
Filters = null
Exceptions = SE_XML
KMScore = 40
KMattr = true
Version = 1.1.1
Request = GetMap
Get = true
RawKvp = {BBOX=-84.494979772443,33.785965102042,-75.285541252023,36.642275921344, VERSION=1.1.1, FORMAT=image/jpeg, SERVICE=WMS, VIEWPARAMS=LocationType:county;LocationID:;EDate:02/21/2013;AgegroupID:1 2 3 4 5 6 7 8 9 10;SyndromeID:3;BDate:02/12/2013, HEIGHT=330, REQUEST=GetMap, LAYERS=ncdetect_test:EDCountByZip, STYLES=, WIDTH=1064, SRS=EPSG:4326}
BaseUrl = http://localhost:8080/geoserver/
RequestCharset = UTF-8
2013-02-22 12:14:21,187 DEBUG [org.geotools.image] - Encoding input image to write out as JPEG.
2013-02-22 12:14:21,187 DEBUG [org.geotools.image] - Getting a JPEG writer and configuring it.
2013-02-22 12:14:21,187 DEBUG [org.geotools.image] - Writing out…

On Fri, Feb 22, 2013 at 6:53 PM, Milton Jonathan <milton@anonymised.com> wrote:

Well ok.

Taking a look at the code, do you think it’s valid to simply add a “typename” in GeoJSONOutputFormat.write()? Doesn’t look complicated…

I guess so. But mind, you might be on an older version, GeoJSON handling
has been refactored lately, I guess what you want to look at is
GeoJSONGetFeatureResponse now

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


Ok thanks.

On sexta-feira, 22 de fevereiro de 2013 14:57:14, Andrea Aime wrote:

On Fri, Feb 22, 2013 at 6:53 PM, Milton Jonathan
<milton@anonymised.com <mailto:milton@anonymised.com>> wrote:

    Well ok.

    Taking a look at the code, do you think it's valid to simply add a
    "typename" in GeoJSONOutputFormat.write()? Doesn't look complicated..

I guess so. But mind, you might be on an older version, GeoJSON handling
has been refactored lately, I guess what you want to look at is
GeoJSONGetFeatureResponse now

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

-------------------------------------------------------

--

Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502