I use OpenLayers(in JavaScript) as client for GeoServer. And I need to programmatically get features infos by user clicking on map. I also need to programmatically operate with this answers. JSON is good for this. I found that GeoServer don't represent GetFeatureInfo in JSON text format. Did anybody use this?
I also found that to activate this feature infos I need to add to wms.jar files and recompile this module.
The files I found is:
1. src/main/java/org/vfny/geoserver/wms/responses/featureinfo/JSONFeatureInfoResponse.java
I will place another class file JSONFeatureInfoResponse that extends AbstractFeatureInfoResponse.
2. src/main/java/org/vfny/geoserver/wms/responses/GetFeatureInfoResponse.java
I will append to List supportedMimeTypes my feature info class like this
producer = new JSONFeatureInfoResponse();
supportedMimeTypes.addAll(producer.getSupportedFormats());
delegates.add(producer);
3. Are any other steps I must to do to activate another GetFeatureInfoRequest? Are my steps correct? Did anybody this work(or I'am the first)?
P.S.
I think the simple response in JSON will be(two features from different layers) :
[
{ // first feature
fid: "Parcel.123",
area: 500.50,
descr: "Text feature description"
}
{ // second feature
fid: "Bounds.44",
place: "afrozodiak"
}
]
To use this in JavaScript:
var resultList=eval('('+response.responseText+')');
resultList.length; // count of features in result
resultList[0].fid; // first feature fid
resultList[1].place; // or resultList[1]["place"] - the situation of second feature
I use OpenLayers(in JavaScript) as client for GeoServer. And I need to programmatically get features infos by user clicking on map. I also need to programmatically operate with this answers. JSON is good for this. I found that GeoServer don't represent GetFeatureInfo in JSON text format. Did anybody use this?
I also found that to activate this feature infos I need to add to wms.jar files and recompile this module.
The files I found is:
1. src/main/java/org/vfny/geoserver/wms/responses/featureinfo/JSONFeatureInfoResponse.java
I will place another class file JSONFeatureInfoResponse that extends AbstractFeatureInfoResponse.
2. src/main/java/org/vfny/geoserver/wms/responses/GetFeatureInfoResponse.java
I will append to List supportedMimeTypes my feature info class like this
producer = new JSONFeatureInfoResponse();
supportedMimeTypes.addAll(producer.getSupportedFormats());
delegates.add(producer);
3. Are any other steps I must to do to activate another GetFeatureInfoRequest? Are my steps correct? Did anybody this work(or I'am the first)?
GetFeatureInfo classes have been negleted for quite some time and
are in some dire need for a restructuring. Anyways, the steps above
do look fine to me, they should work.
Interested in contributing back your JSonFeatureInfoResponse?
But I can't add org.json dependency into pom.xml for maven2. Could you help me? I want to use only org.json.JSONWriter. What the groupId,artifactId,version I need to use in pom.xml?
óÅÍÅÎÅÎËÏ áÎÄÒÅÑ ha scritto:
> Hello, all.
>
> I use OpenLayers(in JavaScript) as client for GeoServer. And I need to programmatically get features infos by user clicking on map. I also need to programmatically operate with this answers. JSON is good for this. I found that GeoServer don't represent GetFeatureInfo in JSON text format. Did anybody use this?
> I also found that to activate this feature infos I need to add to wms.jar files and recompile this module.
> The files I found is:
> 1. src/main/java/org/vfny/geoserver/wms/responses/featureinfo/JSONFeatureInfoResponse.java
> I will place another class file JSONFeatureInfoResponse that extends AbstractFeatureInfoResponse.
> 2. src/main/java/org/vfny/geoserver/wms/responses/GetFeatureInfoResponse.java
> I will append to List supportedMimeTypes my feature info class like this
> producer = new JSONFeatureInfoResponse();
> supportedMimeTypes.addAll(producer.getSupportedFormats());
> delegates.add(producer);
> 3. Are any other steps I must to do to activate another GetFeatureInfoRequest? Are my steps correct? Did anybody this work(or I'am the first)?
GetFeatureInfo classes have been negleted for quite some time and
are in some dire need for a restructuring. Anyways, the steps above
do look fine to me, they should work.
Interested in contributing back your JSonFeatureInfoResponse?
But I can't add org.json dependency into pom.xml for maven2. Could you help me? I want to use only org.json.JSONWriter. What the groupId,artifactId,version I need to use in pom.xml?
WFS already has GeoJson output so you may just want to
have a look there (also for the coding, that is)...
sorry I haven't told you before, I thought you knew.
Anyways, here is what the wfs pom uses (on trunk)
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk13</classifier>
</dependency>
A simple patch to GeoServer for GetFeatureInfo JSON response in attachment.
óÅÍÅÎÅÎËÏ áÎÄÒÅÑ ha scritto:
> Thank you.
>
> But I can't add org.json dependency into pom.xml for maven2. Could you help me? I want to use only org.json.JSONWriter. What the groupId,artifactId,version I need to use in pom.xml?
WFS already has GeoJson output so you may just want to
have a look there (also for the coding, that is)...
sorry I haven't told you before, I thought you knew.
Anyways, here is what the wfs pom uses (on trunk)
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk13</classifier>
</dependency>