Package org.geomajas.configuration

Examples of org.geomajas.configuration.VectorLayerInfo


            document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
            document.writeAttribute("style", "WIDTH: " + coordWidth + "; HEIGHT: " + coordHeight);
          }
          style = nextStyle;

          VectorLayerInfo layerInfo = feature.getLayer().getLayerInfo();
          if (layerInfo.getLayerType() != LayerType.POINT &&
              layerInfo.getLayerType() != LayerType.MULTIPOINT) {

            // the shapetype
            document.writeElement("vml:shapetype", true);
            document.writeAttribute("id", featureStyle.getStyleId());
            document.writeAttribute("style", "WIDTH: 100%; HEIGHT: 100%");
View Full Code Here


    pa2.setType(PrimitiveType.INTEGER);

    attr.add(pa2);
    ft.setAttributes(attr);

    VectorLayerInfo layerInfo = new VectorLayerInfo();
    layerInfo.setFeatureInfo(ft);
    layerInfo.setCrs("EPSG:4326");

    layer.setLayerInfo(layerInfo);
    layer.initFeatures();
  }
View Full Code Here

    pa.setType(PrimitiveType.STRING);

    attr.add(pa);
    ft.setAttributes(attr);

    VectorLayerInfo layerInfo = new VectorLayerInfo();
    layerInfo.setFeatureInfo(ft);
    layerInfo.setCrs("EPSG:4326");

    layer.setLayerInfo(layerInfo);
    layer.initFeatures();
    filter = filterCreator.createCompareFilter(ATTRIBUTE_POPULATION, ">", "1000000");
  }
View Full Code Here

    return result;
  }

  private SimpleFeatureType createFeatureType(VectorLayer layer, CoordinateReferenceSystem mapCrs) {
    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    VectorLayerInfo info = layer.getLayerInfo();
    builder.setName(info.getFeatureInfo().getDataSourceName());
    builder.setCRS(mapCrs);
    for (AttributeInfo attrInfo : info.getFeatureInfo().getAttributes()) {
      if (attrInfo instanceof PrimitiveAttributeInfo) {
        PrimitiveAttributeInfo prim = (PrimitiveAttributeInfo) attrInfo;
        switch (prim.getType()) {
          case BOOLEAN:
            builder.add(prim.getName(), Boolean.class);
            break;
          case CURRENCY:
            builder.add(prim.getName(), BigDecimal.class);
            break;
          case DATE:
            builder.add(prim.getName(), Date.class);
            break;
          case DOUBLE:
            builder.add(prim.getName(), Double.class);
            break;
          case FLOAT:
            builder.add(prim.getName(), Float.class);
            break;
          case INTEGER:
            builder.add(prim.getName(), Integer.class);
            break;
          case LONG:
            builder.add(prim.getName(), Long.class);
            break;
          case SHORT:
            builder.add(prim.getName(), Short.class);
            break;
          case STRING:
          case URL:
          case IMGURL:
            builder.add(prim.getName(), String.class);
            break;
          default:
            throw new IllegalStateException("Unknown primitive attribute type " + prim.getType());
        }
      } else if (attrInfo instanceof AssociationAttributeInfo) {
        AssociationAttributeInfo ass = (AssociationAttributeInfo) attrInfo;
        switch (ass.getType()) {
          case MANY_TO_ONE:
            builder.add(ass.getName(), Object.class);
            break;
          case ONE_TO_MANY:
            builder.add(ass.getName(), Collection.class);
            break;
          default:
            throw new IllegalStateException("Unknown association attribute type " + ass.getType());
        }
      }
    }
    // add the extra style index attribute
    builder.add(STYLE_INDEX_ATTRIBUTE_NAME, Integer.class);
    // add the geometry attribute
    GeometryAttributeInfo geom = info.getFeatureInfo().getGeometryType();
    builder.add(geom.getName(), dtoConverterService.toInternal(info.getLayerType()), mapCrs);
    builder.setDefaultGeometry(geom.getName());
    return builder.buildFeatureType();
  }
View Full Code Here

          getOffset(offset), getLimit(maxFeatures, limit));
    } catch (Exception e) {
      throw new RestException(e, RestException.PROBLEM_READING_LAYERSERVICE, layerId);
    }
    if (features.size() > 0) {
      VectorLayerInfo info = features.get(0).getLayer().getLayerInfo();
      model.addAttribute(VECTOR_LAYER_INFO, info);
      VectorLayer layer = configurationService.getVectorLayer(layerId);
      if (orderBy != null) {
        Collections.sort(features, createComparator(layer, orderBy, dir));
      }
View Full Code Here

  @Override
  protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    Object ff = model.get(RestController.FEATURE_COLLECTION);
    VectorLayerInfo info = (VectorLayerInfo) model.get(RestController.VECTOR_LAYER_INFO);
    List<String> attrs = (List<String>) model.get(RestController.ATTRIBUTES);
    SimpleFeatureType sft = convertorService.toSimpleFeatureType(info, attrs);
    response.setContentType(getContentType());
    if (Collection.class.isAssignableFrom(ff.getClass())) {
      Collection<InternalFeature> features = (Collection<InternalFeature>) ff;
View Full Code Here

    ClientLayerInfo layer = layers.get(0);
    Assert.assertEquals(CLIENT_LAYER_ID, layer.getId());
    Assert.assertEquals(LAYER_ID, layer.getServerLayerId());
    Assert.assertEquals("Test beans", layer.getLabel());
    Assert.assertTrue(layer.getLayerInfo() instanceof VectorLayerInfo);
    VectorLayerInfo vectorLayerInfo = ((VectorLayerInfo)layer.getLayerInfo());
    Assert.assertEquals("EPSG:4326", vectorLayerInfo.getCrs());
    Assert.assertNotNull(vectorLayerInfo.getFeatureInfo());
    FeatureInfo featureInfo = vectorLayerInfo.getFeatureInfo();
    List<AttributeInfo> attributes = featureInfo.getAttributes();
    Assert.assertNotNull(attributes);
    Assert.assertEquals(1, attributes.size());
    Assert.assertEquals("stringAttr", attributes.get(0).getName());
  }
View Full Code Here

      try {
        ClientMapInfo map = configurationService.getMapInfo(getMap().getMapId(), getMap().getApplicationId());

        // If MapCRS does not equal LayerCRS then instantiate
        // the CrsTransform which will be used for transforming the bbox
        VectorLayerInfo layerInfo = configurationService.getVectorLayerInfo(getLayerId());
        String mapCrs = map.getCrs();
        String layerCrs = layerInfo.getCrs();
        Envelope layerBbox = bbox;
        if (!mapCrs.equals(layerCrs)) {
          layerBbox = geoService.transform(layerBbox, mapCrs, layerCrs);
        }

        String geomName = layerInfo.getFeatureInfo().getGeometryType().getName();

        // If the transform is null then just use the bbox for the filter
        // Else if the transform is not null then transform the bbox for the filter
        Filter filter = filterService.createBboxFilter(layerCrs, layerBbox, geomName);
View Full Code Here

      info.getResolutions().add(1. / scale.getPixelPerUnit());
    }
  }

  private void postProcess(VectorLayer layer) throws LayerException {
    VectorLayerInfo info = layer.getLayerInfo();
    if (info != null) {
      // check for invalid attribute names
      for (AttributeInfo attributeInfo : info.getFeatureInfo().getAttributes()) {
        if (attributeInfo.getName().contains(".") || attributeInfo.getName().contains("/")) {
          throw new LayerException(ExceptionCode.INVALID_ATTRIBUTE_NAME, attributeInfo.getName(),
              layer.getId());
        }
      }
      // apply defaults to all styles
      for (NamedStyleInfo namedStyle : info.getNamedStyleInfos()) {
        // check sld location
        if (namedStyle.getSldLocation() != null) {
          Resource resource = applicationContext.getResource(namedStyle.getSldLocation());
          IBindingFactory bindingFactory;
          try {
            bindingFactory = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
            IUnmarshallingContext unmarshallingContext = bindingFactory.createUnmarshallingContext();
            StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) unmarshallingContext
                .unmarshalDocument(new InputStreamReader(resource.getInputStream()));
            namedStyle.setStyledLayerInfo(sld);
          } catch (JiBXException e) {
            throw new LayerException(e, ExceptionCode.INVALID_SLD, namedStyle.getSldLocation(),
                layer.getId());
          } catch (IOException e) {
            throw new LayerException(e, ExceptionCode.INVALID_SLD, namedStyle.getSldLocation(),
                layer.getId());
          }
          String layerName = (namedStyle.getSldLayerName() != null ? namedStyle.getSldLayerName() : layer
              .getId());
          String styleName = (namedStyle.getSldStyleName() != null ? namedStyle.getSldStyleName() : layer
              .getId());
          NamedStyleInfo sldStyle = styleConverterService.convert(namedStyle.getStyledLayerInfo(),
              info.getFeatureInfo(), layerName, styleName);
          namedStyle.setFeatureStyles(sldStyle.getFeatureStyles());
          namedStyle.setLabelStyle(sldStyle.getLabelStyle());
        }
      }
      // apply defaults to all styles
      for (NamedStyleInfo namedStyle : info.getNamedStyleInfos()) {
        for (FeatureStyleInfo featureStyle : namedStyle.getFeatureStyles()) {
          featureStyle.applyDefaults();
        }
        if (namedStyle.getLabelStyle().getLabelAttributeName() == null) {
          AttributeInfo attributeInfo = info.getFeatureInfo().getAttributes().get(0);
          namedStyle.getLabelStyle().setLabelAttributeName(attributeInfo.getName());
        }
        namedStyle.getLabelStyle().getBackgroundStyle().applyDefaults();
        namedStyle.getLabelStyle().getFontStyle().applyDefaults();
      }
View Full Code Here

  }

  private ClientVectorLayerInfo postProcess(ClientVectorLayerInfo layer) throws LayerException {
    // copy feature info from server if not explicitly defined
    if (layer.getFeatureInfo() == null) {
      VectorLayerInfo serverInfo = (VectorLayerInfo) layer.getLayerInfo();
      layer.setFeatureInfo(serverInfo.getFeatureInfo());
    }

    return layer;
  }
View Full Code Here

TOP

Related Classes of org.geomajas.configuration.VectorLayerInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.