[Geoserver-devel] register FeatureType on-the-fly

Dear developers,

Currently, I am working on a webapp where users can upload a geo-related dataset for a certain year. Based on an identifier (i.c. a city code), geometry objects for that specific year are merged into the dataset in the users HttpSession and a cartographic map will be made on the basis of the dataset. To give you an idea, uploaded data can be e.g. 'the percentage of double-income families per city in 1971' or 'population compactness per city in 1889'. For processing the dataset, I have made a custom DataStore and a custom FeatureReader that can read the elements in the dataset.

I have configured the custom datastore in Geoserver via catalog.xml. I have a static list of HttpSessions that I can access from the datastore to retrieve the correct HttpSession to access the user's dataset. But, Geoserver reads the available FeatureTypes at startup, so I am now looking for a way to register new FeatureTypes (from a HttpSession) with Geoserver on-the-fly, so that they will be recognized when a WMS-request is received by Geoserver for these dynamic FeatureTypes.

However, I don't know what the best way is to achieve this. My current version of Geoserver is 1.3.0a. Can anyone help me out?

Thanks in advance and best regards,

Dave

Dave wrote:

However, I don't know what the best way is to achieve this. My current version of Geoserver is 1.3.0a. Can anyone help me out?

You can do it the same way the config layer does it, make some DTO objects describing the configuration and pass them into the application. Remember even if the datastore has new content available there is additional information that geoserver needs passed in via the configuration in order to function (the bounds in lat/long for example).

Cheers,
Jody

Hi Dave,
I think that the best way to let GeoServer recognize your new FeatureType is to store the latter in memory by adding it to the Data.

You can retrieve the GeoServer DataConfig by executing this code:
(DataConfig) getServlet().getServletContext().getAttribute(DataConfig.CONFIG_KEY);

now you can call the addFetureType method by doing:
dataConfig.addFeatureType(…)

don’t forget to notify the changed state to GeoServer:
((ApplicationState)getServlet().getServletContext().getAttribute(ApplicationState.WEB_CONTAINER_KEY)).notifyConfigChanged();

On 4/18/06, Dave < dave.schoorl@anonymised.com> wrote:

Dear developers,

Currently, I am working on a webapp where users can upload a geo-related
dataset for a certain year. Based on an identifier (i.c. a city code),
geometry objects for that specific year are merged into the dataset in
the users HttpSession and a cartographic map will be made on the basis
of the dataset. To give you an idea, uploaded data can be e.g. ‘the
percentage of double-income families per city in 1971’ or ‘population
compactness per city in 1889’. For processing the dataset, I have made a
custom DataStore and a custom FeatureReader that can read the elements
in the dataset.

I have configured the custom datastore in Geoserver via catalog.xml. I
have a static list of HttpSessions that I can access from the datastore
to retrieve the correct HttpSession to access the user’s dataset. But,
Geoserver reads the available FeatureTypes at startup, so I am now
looking for a way to register new FeatureTypes (from a HttpSession) with
Geoserver on-the-fly, so that they will be recognized when a WMS-request
is received by Geoserver for these dynamic FeatureTypes.

However, I don’t know what the best way is to achieve this. My current
version of Geoserver is 1.3.0a. Can anyone help me out?

Thanks in advance and best regards,

Dave


This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642


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

Alessio Fabiani
Software Engineer

http://docs.codehaus.org/display/~afabiani


Thanks for the responses. I had some other challanges to attend to before I could try this out, but it works ok. Especially the detailed instructions of Allessio Fabiani really helped. Thanks.

However, I have taken out the admin interface, so the notifyChangedState() does not do much than, but I now mimic what it does, that is, call Data.load(). For now, that works, but that will reload the entire FeatureType configuration, which takes more time than necessary (considering I only register/unregister one FeatureType at a time, but all FeatureTypes are (re)loaded again).

When this proves to be non-performing in a life situation, because too often FeatureTypes are added/removed, I guess the only valid option for me would be to change the Data- and DataConfig class and let DataConfig.addFeatureType call something like Data.registerFeatureType() which will be a new method that will validate the FeatureType provided and add only this FeatureType to the Data-object. Am I correct or is there another solution?

Thanks again,

Dave

Alessio Fabiani wrote:

Hi Dave,
I think that the best way to let GeoServer recognize your new FeatureType is to store the latter in memory by adding it to the Data.

You can retrieve the GeoServer DataConfig by executing this code:
(DataConfig) getServlet().getServletContext().getAttribute(DataConfig.CONFIG_KEY);

now you can call the addFetureType method by doing:
dataConfig.addFeatureType(...)

don't forget to notify the changed state to GeoServer:
((ApplicationState)getServlet().getServletContext().getAttribute(ApplicationState.WEB_CONTAINER_KEY)).notifyConfigChanged();

On 4/18/06, *Dave* < dave.schoorl@anonymised.com <mailto:dave.schoorl@anonymised.com>> wrote:

    Dear developers,

    Currently, I am working on a webapp where users can upload a
    geo-related
    dataset for a certain year. Based on an identifier (i.c. a city code),
    geometry objects for that specific year are merged into the dataset in
    the users HttpSession and a cartographic map will be made on the
    basis
    of the dataset. To give you an idea, uploaded data can be e.g. 'the
    percentage of double-income families per city in 1971' or 'population
    compactness per city in 1889'. For processing the dataset, I have
    made a
    custom DataStore and a custom FeatureReader that can read the elements
    in the dataset.

    I have configured the custom datastore in Geoserver via catalog.xml. I
    have a static list of HttpSessions that I can access from the
    datastore
    to retrieve the correct HttpSession to access the user's
    dataset. But,
    Geoserver reads the available FeatureTypes at startup, so I am now
    looking for a way to register new FeatureTypes (from a
    HttpSession) with
    Geoserver on-the-fly, so that they will be recognized when a
    WMS-request
    is received by Geoserver for these dynamic FeatureTypes.

    However, I don't know what the best way is to achieve this. My current
    version of Geoserver is 1.3.0a. Can anyone help me out?

    Thanks in advance and best regards,

    Dave

    -------------------------------------------------------
    This SF.Net email is sponsored by xPML, a groundbreaking scripting
    language
    that extends applications into web and mobile media. Attend the
    live webcast
    and join the prime developer group breaking into this new coding
    territory!
    http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642&gt;
    _______________________________________________
    Geoserver-devel mailing list
    Geoserver-devel@lists.sourceforge.net
    <mailto:Geoserver-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
---------------------------------------------------------
Alessio Fabiani
Software Engineer

http://docs.codehaus.org/display/~afabiani <http://docs.codehaus.org/display/~afabiani&gt;

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