Search in sources :

Example 1 with LogSlow

use of org.activityinfo.server.util.logging.LogSlow in project activityinfo by bedatadriven.

the class ImageMapRenderer method drawAdminOverlay.

@LogSlow(threshold = 50)
protected void drawAdminOverlay(TiledMap map, Graphics2D g2d, AdminOverlay overlay) {
    List<AdminGeo> geometry = geometryProvider.getGeometries(overlay.getAdminLevelId());
    Color strokeColor = ColorUtil.colorFromString(overlay.getOutlineColor());
    g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    for (AdminGeo adminGeo : geometry) {
        AdminMarker polygon = overlay.getPolygon(adminGeo.getId());
        if (polygon != null) {
            GeneralPath path = PathUtils.toPath(map, adminGeo.getGeometry());
            g2d.setColor(bubbleFillColor(ColorUtil.colorFromString(polygon.getColor())));
            g2d.fill(path);
            g2d.setColor(strokeColor);
            g2d.draw(path);
        }
    }
}
Also used : BasicStroke(com.google.code.appengine.awt.BasicStroke) AdminGeo(org.activityinfo.server.geo.AdminGeo) GeneralPath(com.google.code.appengine.awt.geom.GeneralPath) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) Color(com.google.code.appengine.awt.Color) LogSlow(org.activityinfo.server.util.logging.LogSlow)

Example 2 with LogSlow

use of org.activityinfo.server.util.logging.LogSlow in project activityinfo by bedatadriven.

the class ImageMapRenderer method drawGoogleBaseMap.

@LogSlow(threshold = 100)
protected void drawGoogleBaseMap(TileHandler tileHandler, TiledMap map, GoogleBaseMap baseMap) throws IOException {
    for (int x = 0; x < map.getWidth(); x += GoogleStaticMapsApi.MAX_WIDTH) {
        for (int y = 0; y < map.getHeight(); y += GoogleStaticMapsApi.MAX_HEIGHT) {
            int sliceWidth = Math.min(GoogleStaticMapsApi.MAX_WIDTH, map.getWidth() - x);
            int sliceHeight = Math.min(GoogleStaticMapsApi.MAX_HEIGHT, map.getHeight() - y);
            AiLatLng sliceCenter = map.fromPixelToLatLng(x + (sliceWidth / 2), y + (sliceHeight / 2));
            String tileUrl = GoogleStaticMapsApi.buildRequest().setBaseMap(baseMap).setCenter(sliceCenter).setWidth(sliceWidth).setHeight(sliceHeight).setZoom(map.getZoom()).urlString();
            tileHandler.addTile(tileUrl, x, y, sliceWidth, sliceHeight);
        }
    }
}
Also used : AiLatLng(org.activityinfo.shared.report.content.AiLatLng) LogSlow(org.activityinfo.server.util.logging.LogSlow)

Example 3 with LogSlow

use of org.activityinfo.server.util.logging.LogSlow in project activityinfo by bedatadriven.

the class WkbGeometryProvider method getGeometries.

@Override
@LogSlow(threshold = 200)
public List<AdminGeo> getGeometries(int adminLevelId) {
    try {
        List<AdminGeo> list = Lists.newArrayList();
        DataInputStream in = new DataInputStream(storage.openWkb(adminLevelId));
        WKBReader wkbReader = new WKBReader(geometryFactory);
        int count = in.readInt();
        for (int i = 0; i != count; ++i) {
            int id = in.readInt();
            LOGGER.info("Reading geometry for admin entity " + id);
            Geometry geometry = wkbReader.read(new DataInputInStream(in));
            list.add(new AdminGeo(id, geometry));
        }
        return list;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) IOException(java.io.IOException) ParseException(com.vividsolutions.jts.io.ParseException) DataInputStream(java.io.DataInputStream) WKBReader(com.vividsolutions.jts.io.WKBReader) LogSlow(org.activityinfo.server.util.logging.LogSlow)

Aggregations

LogSlow (org.activityinfo.server.util.logging.LogSlow)3 BasicStroke (com.google.code.appengine.awt.BasicStroke)1 Color (com.google.code.appengine.awt.Color)1 GeneralPath (com.google.code.appengine.awt.geom.GeneralPath)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 ParseException (com.vividsolutions.jts.io.ParseException)1 WKBReader (com.vividsolutions.jts.io.WKBReader)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 AdminGeo (org.activityinfo.server.geo.AdminGeo)1 AdminMarker (org.activityinfo.shared.report.content.AdminMarker)1 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)1