org.geomajas.internal.layer.RasterLayerServiceImpl Maven / Gradle / Ivy
/*
* This file is part of Geomajas, a component framework for building
* rich Internet applications (RIA) with sophisticated capabilities for the
* display, analysis and management of geographic information.
* It is a building block that allows developers to add maps
* and other geographic data capabilities to their web applications.
*
* Copyright 2008-2010 Geosparc, http://www.geosparc.com, Belgium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package org.geomajas.internal.layer;
import com.vividsolutions.jts.geom.Envelope;
import org.geomajas.global.ExceptionCode;
import org.geomajas.global.GeomajasException;
import org.geomajas.security.GeomajasSecurityException;
import org.geomajas.layer.RasterLayer;
import org.geomajas.layer.tile.RasterTile;
import org.geomajas.service.pipeline.PipelineCode;
import org.geomajas.service.pipeline.PipelineContext;
import org.geomajas.service.pipeline.PipelineService;
import org.geomajas.security.SecurityContext;
import org.geomajas.service.ConfigurationService;
import org.geomajas.service.GeoService;
import org.geomajas.layer.RasterLayerService;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of {@link org.geomajas.layer.RasterLayerService}, a service which allows accessing data from a
* raster layer.
*
* All access to vector layers should be done through this service, not by accessing the layer directly as this
* adds possible caching, security etc. These services are implemented using pipelines (see
* {@link org.geomajas.service.pipeline.PipelineService}) to make them configurable.
*
* @author Joachim Van der Auwera
*/
@Component
public class RasterLayerServiceImpl implements RasterLayerService {
@Autowired
private ConfigurationService configurationService;
@Autowired
private SecurityContext securityContext;
@Autowired
private GeoService geoService;
@Autowired
private PipelineService pipelineService;
private RasterLayer getRasterLayer(String layerId) throws GeomajasException {
if (!securityContext.isLayerVisible(layerId)) {
throw new GeomajasSecurityException(ExceptionCode.LAYER_NOT_VISIBLE, layerId, securityContext.getUserId());
}
RasterLayer layer = configurationService.getRasterLayer(layerId);
if (null == layer) {
throw new GeomajasException(ExceptionCode.RASTER_LAYER_NOT_FOUND, layerId);
}
return layer;
}
public List getTiles(String layerId, CoordinateReferenceSystem crs, Envelope bounds, double scale)
throws GeomajasException {
PipelineContext context = pipelineService.createContext();
context.put(PipelineCode.LAYER_ID_KEY, layerId);
RasterLayer layer = getRasterLayer(layerId);
context.put(PipelineCode.LAYER_KEY, layer);
context.put(PipelineCode.CRS_KEY, crs);
context.put(PipelineCode.BOUNDS_KEY, bounds);
context.put(PipelineCode.SCALE_KEY, scale);
List response = new ArrayList();
pipelineService.execute(PipelineCode.PIPELINE_GET_RASTER_TILES, layerId, context, response);
return response;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy