Package org.geomajas.layer

Examples of org.geomajas.layer.LayerException


      return null;
    } else if (Geometry.class.isAssignableFrom(obj.getClass())) {
      Geometry geom = (Geometry) obj;
      return (Geometry) geom.clone();
    } else {
      throw new LayerException(ExceptionCode.PROPERTY_IS_NOT_GEOMETRY, getGeometryAttributeName());
    }
  }
View Full Code Here


  public Object newInstance() throws LayerException {
    try {
      return getEntityMetadata().instantiate(null, (SessionImplementor) getSessionFactory().getCurrentSession());
    } catch (Exception e) {
      throw new LayerException(e, ExceptionCode.HIBERNATE_CANNOT_CREATE_POJO, getFeatureInfo()
          .getDataSourceName());
    }
  }
View Full Code Here

    try {
      Serializable ser = (Serializable) ConvertUtils.convert(id, getEntityMetadata().getIdentifierType()
          .getReturnedClass());
      return getEntityMetadata().instantiate(ser, (SessionImplementor) getSessionFactory().getCurrentSession());
    } catch (Exception e) {
      throw new LayerException(e, ExceptionCode.HIBERNATE_CANNOT_CREATE_POJO, getFeatureInfo()
          .getDataSourceName());
    }
  }
View Full Code Here

        res = CrsFactory.getCrs(crs, CRS.decode(crs));
        crsCache.put(crs, res);
      }
      return res;
    } catch (NoSuchAuthorityCodeException e) {
      throw new LayerException(e, ExceptionCode.CRS_DECODE_FAILURE_FOR_MAP, crs);
    } catch (FactoryException e) {
      throw new LayerException(e, ExceptionCode.CRS_DECODE_FAILURE_FOR_MAP, crs);
    }
  }
View Full Code Here

  private void postProcess(RasterLayer layer) throws LayerException {
    RasterLayerInfo info = layer.getLayerInfo();
    for (ScaleInfo scale : info.getZoomLevels()) {
      // for raster layers we don't accept x:y notation !
      if (scale.getDenominator() != 0) {
        throw new LayerException(ExceptionCode.CONVERSION_PROBLEM, "Raster layer " + layer.getId()
            + " has zoom level " + scale.getNumerator() + ":" + scale.getDenominator()
            + " in disallowed x:y notation");
      }
      // add the resolution for deprecated api support
      info.getResolutions().add(1. / scale.getPixelPerUnit());
View Full Code Here

    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
View Full Code Here

      boolean relativeScales = true;
      for (ScaleInfo scale : map.getScaleConfiguration().getZoomLevels()) {
        if (scale.getDenominator() == 0) {
          relativeScales = false;
        } else if (!relativeScales) {
          throw new LayerException(ExceptionCode.SCALE_CONVERSION_PROBLEM, map.getId());
        }
        completeScale(scale, pixPerUnit);
        // add the resolution for deprecated api support
        if (!map.isResolutionsRelative()) {
          map.getResolutions().add(1. / scale.getPixelPerUnit());
        } else {
          map.getResolutions().add(scale.getDenominator() / scale.getNumerator());
        }
      }
      completeScale(map.getScaleConfiguration().getMaximumScale(), pixPerUnit);
      for (ClientLayerInfo layer : map.getLayers()) {
        String layerId = layer.getServerLayerId();
        Layer<?> serverLayer = layerMap.get(layerId);
        if (serverLayer == null) {
          throw new LayerException(ExceptionCode.LAYER_NOT_FOUND, layerId);
        }
        LayerInfo layerInfo = serverLayer.getLayerInfo();
        layer.setLayerInfo(layerInfo);
        layer.setMaxExtent(getClientMaxExtent(map.getCrs(), layer.getCrs(), layerInfo.getMaxExtent(), layerId));
        completeScale(layer.getMaximumScale(), pixPerUnit);
View Full Code Here

  }

  private double getUnitLength(String mapCrsKey, Bbox mapBounds) throws LayerException {
    try {
      if (null == mapBounds) {
        throw new LayerException(ExceptionCode.MAP_MAX_EXTENT_MISSING);
      }
      Crs crs = geoService.getCrs2(mapCrsKey);
      GeodeticCalculator calculator = new GeodeticCalculator(crs);
      Coordinate center = new Coordinate(0.5 * (mapBounds.getX() + mapBounds.getMaxX()),
          0.5 * (mapBounds.getY() + mapBounds.getMaxY()));
      calculator.setStartingPosition(new DirectPosition2D(crs, center.getX(), center.getY()));
      calculator.setDestinationPosition(new DirectPosition2D(crs, center.getX() + 1, center.getY()));
      return calculator.getOrthodromicDistance();
    } catch (TransformException e) {
      throw new LayerException(e, ExceptionCode.TRANSFORMER_CREATE_LAYER_TO_MAP_FAILED);
    }
  }
View Full Code Here

      Envelope serverEnvelope = converterService.toInternal(serverBbox);
      CrsTransform transformer = geoService.getCrsTransform(layerCrs, mapCrs);
      Bbox res = converterService.toDto(geoService.transform(serverEnvelope, transformer));
      if (Double.isNaN(res.getX()) || Double.isNaN(res.getY()) || Double.isNaN(res.getWidth())
          || Double.isNaN(res.getHeight())) {
        throw new LayerException(ExceptionCode.LAYER_EXTENT_CANNOT_CONVERT, layer, mapCrsKey);
      }
      return res;
    } catch (GeomajasException e) {
      throw new LayerException(e, ExceptionCode.TRANSFORMER_CREATE_LAYER_TO_MAP_FAILED);
    }
  }
View Full Code Here

TOP

Related Classes of org.geomajas.layer.LayerException

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.