Exemplo n.º 1
0
  private OWSContextType createJaxbMapContext() {
    // Create jaxbcontext data
    ObjectFactory ows_context_factory = new ObjectFactory();
    net.opengis.ows._2.ObjectFactory ows_factory = new net.opengis.ows._2.ObjectFactory();

    OWSContextType mapContextSerialisation = ows_context_factory.createOWSContextType();

    // GeneralType
    mapContextSerialisation.setGeneral(ows_context_factory.createGeneralType());

    // GeneralType:Bounding Box
    if (boundingBox != null) {
      BoundingBoxType bbox = ows_factory.createBoundingBoxType();
      bbox.getLowerCorner().add(boundingBox.getMinX());
      bbox.getLowerCorner().add(boundingBox.getMinY());
      bbox.getUpperCorner().add(boundingBox.getMaxX());
      bbox.getUpperCorner().add(boundingBox.getMaxY());
      mapContextSerialisation.getGeneral().setBoundingBox(ows_factory.createBoundingBox(bbox));
    }
    // GeneralType:Title
    Map<Locale, String> titles = description.getTitles();
    if (!titles.isEmpty()) {
      // Take the first one
      for (Entry<Locale, String> entry : titles.entrySet()) {
        LanguageStringType title = ows_factory.createLanguageStringType();
        title.setLang(LocalizedText.toLanguageTag(entry.getKey()));
        title.setValue(entry.getValue());
        mapContextSerialisation.getGeneral().setTitle(title);
        break; // Ows-context does not support multi-lingual
      }
    }
    // GeneralType:Abstract
    Map<Locale, String> abstracts = description.getAbstractTexts();
    if (!abstracts.isEmpty()) {
      // Take the first one
      for (Entry<Locale, String> entry : abstracts.entrySet()) {
        LanguageStringType mapAbstract = ows_factory.createLanguageStringType();
        mapAbstract.setLang(LocalizedText.toLanguageTag(entry.getKey()));
        mapAbstract.setValue(entry.getValue());
        mapContextSerialisation.getGeneral().setAbstract(mapAbstract);
        break; // Ows-context does not support multi-lingual
      }
    }
    // ResourceList
    ResourceListType rs = ows_context_factory.createResourceListType();
    mapContextSerialisation.setResourceList(rs);

    // LayerList
    if (layerModel != null) {
      List<LayerType> rootLayerList = rs.getLayer();
      ILayer[] rootLayers = layerModel.getChildren();
      for (ILayer layer : rootLayers) {
        if (layer.isSerializable()) {
          rootLayerList.add(createJAXBFromLayer(layer, this));
        }
      }
    }
    return mapContextSerialisation;
  }