1

I´m new to GIS development. I have read about Openlayers, maps servers (I choose Geoserver), geodatabase (in my case i choose PostGIS) and theory of GIS in general. I´m developing a Java EE application that needs GIS functionality, but i´m having some problems defining the high level architecture for my requirements. Before i explain what alternatives i´m considering, i think it´s best if I give the main requirements that the present application must fulfill:

  • It has to show a map on the browser, with several layers. Among the features that it has to show, are points that represents cities, or users, etc. In some of this features the user is allowed to click and a pop up should appear with related information, and effects like that.

  • For some of the layers, the users may see only some information (i.e, some of the features) but not all, and this is based on some custom domain logic that its implemented server side with java EE.

  • The users can modify some map information. They may create certain new features or modify existing ones, but all of these is based on custom logic implemented server side. They can also move through the map, and other users should be capable of seeing this updates.

So, i have a lot of questions regarding how i should design something like this. My first question is:

  • Should i use WMS or WFS services? As the users will be modifying things on the map, i first think of using WFS services. But, remember that all the operations that modify the map require specific domain logic in order to validate the update, before hitting in the data store. So perhaps i can access directly into the database from java and let the user retrieve the map from a WMS service. At the same time, i´m not so sure about this, because then i´ll be hitting the data base from two sides (Geoserver and jdbc or jpa or whatever) and i don´t know what kinds of problems could arise.

  • Lets suppose i pick one of the previous services. How could be client-side logic be implemented? I think that with Ajax i can request the application to see if i can validate the operation on the map, and if the validation is succesful then make a call with Openlayers to the service in Geoserver (i don´t know if this is good, since the client ends up making two remote calls, one to the java EE app and other to Geoserver in order to retrieve the ¨results¨ (map)). Or how can i accomplish this? Thinking about this i´m not even sure about why I should be using a map server at all, since i have to do some geographical validations in the map before serving the geographical information.. perhaps i can just query PostGIS and serve the contents directly to openlayers through the ajax call if the previous validations pass? or is it possible to pass the validation logic to geoserver somehow?

As you can see, these are some fundamental questions and decisions I have to made before doing anything else, and I was hoping for advice and other alternatives as well.

  • 3
    Maybe someone with more experience with those platforms can provide some direction, but it sounds to me like you are asking too many questions at once. This site works best with singular, focused questions that have definite answers. Of course there are plenty of examples of "advice" questions here as well, but the results tend to be mixed and they are often closed as being unclear or too broad. – blah238 Jan 27 '14 at 17:00
  • I think that, besides the specific platforms i´m using, the problem is more fundamental. It´s about how to implement a GIS web system that depends on some custom domain logic that it´s checked server-side. I provided more information only to provide some context to the question, but in fact you can replace Geoserver for any other map server, and the same goes for openlayers and postgis for any other datastore... perhaps the original question is misleading by mentioning all those technologies... if it is, im sorry! – Lucia Jan 27 '14 at 17:05
  • I'm doing EXACTLY this. I'm using 3 Tomcat servers for my game: 1) Client controller (The Map and etc.) communicates via GEOJSON with 2) GeoProcessor and Database server (provides json data and accept json commands to database). And 3) The Moviment server (Have the "heartbeat" for the game - a cron - and communicates with 2). Greetings from Brasil. – Magno C Jan 27 '14 at 18:16
  • Im too developing a similar kind of application. @Magno C can you please share the document describing all process in details – Fahim Farook Jun 24 '14 at 18:33
  • @Fahim Farook sorry but I'm too busy for now. I'm working in a too complicated project and put this on hold. You can see my answer (the accepted one below) and deduce all process. – Magno C Jun 26 '14 at 11:04
1

Dont be complicated if you can be simple.

1) Client-side: pure jQuery and html. JSON + Ajax to communicate with server.

function loadCities() {
    var mapbounds = map.getExtent();
    mapbounds.transform(toProjection, fromProjection );
    bbox = mapbounds.toArray();
    var bleft = bbox[0];
    var bbottom = bbox[1];
    var bright = bbox[2];
    var btop = bbox[3];
    showLoader();
    var origem = "getCities?bleft=" + bleft + "&bbottom=" + bbottom + "&bright=" + bright + "&btop=" + btop;
    $.ajax({
            url: origem,
            dataType: "json"
    }).always(function() { hideLoader(); }).done(function(data) {
        data = eval( data );
        var geojson_format = new OpenLayers.Format.GeoJSON({
            'internalProjection': map.baseLayer.projection,
            'externalProjection': new OpenLayers.Projection("EPSG:4326")
        });
        citiesLayer.removeAllFeatures();
        citiesLayer.addFeatures(geojson_format.read(data));
    });     
}

2) Server side: Struts Actions configured to JSON responses:

    @Action(value="getCities", results= {  
            @Result(name="ok", type="httpheader", params={"status", "200"}) }
    )  

@ParentPackage("default")
public class GetCitiesAction  {

    public String execute(){
    HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);  
    Double bleft = Double.parseDouble( request.getParameter("bleft") );
    Double bbottom = Double.parseDouble( request.getParameter("bbottom") );
    Double bright = Double.parseDouble( request.getParameter("bright") );
    Double btop = Double.parseDouble( request.getParameter("btop") );
    int idUsuario = Integer.valueOf( request.getParameter("idUsuario") );

    String resposta = "";

        try {
            CityController cc = new CityController( idUsuario );
            IStaticElementList lista = cc.getCitiesInBBOX( bleft, bbottom, bright, btop );
            resposta = lista.asJson();
        } catch ( Exception e ) {
            e.printStackTrace();
        }

        try { 
            HttpServletResponse response = (HttpServletResponse)ActionContext.getContext().get(StrutsStatics.HTTP_RESPONSE);
            response.setCharacterEncoding("UTF-8"); 
            response.getWriter().write(resposta);  
        } catch (IOException ex) {  
            ex.printStackTrace();
        }

        return "ok";
       }
 }

Hybernate to database access. Don't forget to keep the domains. See Domain Driven Design. Mail me if in doubt (see my profile).

enter image description here

  • Hi! Thank you very much for such a detailed answer! :) I have some more doubts about this so i will contact you by email as you said – Lucia Jan 28 '14 at 13:19
  • @Lucia: Just you to know I'm preparing a document describing all process in details. Later I'll release it for download. – Magno C Jan 31 '14 at 13:42
1

Should i use WMS or WFS services?

Since you are planning on implementing custom logic, I would recommend using WMS and make sure you disable WFS. One possible interface for editing: when the user selects a feature on the map, the properties of that feature appear in a popup. These properties are editable in the popup.

i´ll be hitting the data base from two sides ... and i don´t know what kinds of problems could arise

Databases have this property called ACID that means transactions are processed in a very predictable manner. You should read more about it, but it generally means that there won't be fatal errors.

i´m not even sure about why i should be using a map server at all, since i have to do some geographical validations in the map before serving the geographical information

The advantage of the map server is that it renders the images ahead of time then sends it to the client. This means less processing client-side. If you made all the requests manually, you would essentially be rewriting the OpenLayers WMS Layer class... without any advantages.

Overall, you should separate viewing the map and editing the map (since you have specific processing requirements). Use OpenLayers and GeoServer to put the map on the screen. Use things like popups filled with textboxes to allow the user to make edits.

  • Thanks! I assume then that you agree with the approach of modifying the database directly from the application (and not for example through some Geoserver WFS or REST service). Is it so?? The pattern then would be letting the app modify the database, and for viewing access through WMS from client side? But i have to restrict what users should be seeing too, shouldn´t i go before to the application in order to know what to allow seeing and then consume the WMS service? I´m sorry if didn´t understand something. – Lucia Jan 28 '14 at 13:26
  • Yes, I agree with the approach of modifying the database from the application. – Brynne Jan 28 '14 at 18:07
  • Could you expand on your requirements on letting users see only a subset of the data? – Brynne Jan 28 '14 at 18:07
  • For example, depending on some users attributes they may not see some of the cities that exists in the map. Or in order to see some feature they may depend on other users attributes too, and in attributes of the target feature they want to see, and in general the rule that allows them to see something may be complex and involve some domain-specific calculations. – Lucia Jan 29 '14 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.