Ejemplo n.º 1
0
 private static void paintLayer(
     Graphics2D g, String layerName, Layers layers, WmsRequest request) {
   log.info("painting " + layerName);
   final Layer layer = layers.getLayer(layerName);
   if (layer != null) {
     layer.render(g, request);
     log.info("finished painting " + layerName);
   } else log.warn("no paintImage implementation for layer: " + layerName);
 }
Ejemplo n.º 2
0
 Map<String, String> getInfos(Date time, WmsRequest request, Point point, String mimeType) {
   Map<String, String> map = new HashMap<String, String>();
   for (String layerName : request.getLayers()) {
     Layer layer = layers.getLayer(layerName);
     if (layer != null) {
       String info = layer.getInfo(time, request, point, mimeType);
       if (info != null) map.put(layerName, info);
     } else log.warn("no getInfo implementation for layer: " + layerName);
   }
   return map;
 }
Ejemplo n.º 3
0
  private void loadEntities(InputStream is) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    String line;

    Set<String> uniqueDisplayNames = new HashSet<String>();

    // TODO(dkogan): We're currently dropping entities with the same
    // name on the floor (e.g. we keep only one rib). Need to come
    // up with a better scheme so we can cycle through 'dups'.
    while ((line = reader.readLine()) != null) {
      String layer = line;
      int layerId = Layers.fromName(layer);

      while ((line = reader.readLine()) != null) {
        if ("".equals(line)) break;

        // Using substring() instead of split() is about 30% faster.
        // Explicitly use |new String()| because just substring() makes
        // the substring a view of the original string, which wastes
        // memory.
        int startIndex = 0, endIndex = line.indexOf(FIELD_SEPARATOR);
        String entityId = new String(line.substring(startIndex, endIndex));
        startIndex = endIndex + 1;
        endIndex = line.indexOf(FIELD_SEPARATOR, startIndex);
        String entityName = new String(line.substring(startIndex, endIndex));

        // Map of entity id to coordinate info (bbox, ctr).
        EntityInfo entityInfo = parseEntityInfo(line, endIndex + 1);
        entityInfo.layer = layerId;
        entityInfo.displayName = entityName;
        mEntities.put(entityId, entityInfo);

        // Map of display name to entity id.
        if (!uniqueDisplayNames.contains(entityName)) {
          mSearchList.add(entityName);
          uniqueDisplayNames.add(entityName);
          mSearchToEntity.put(entityName, new ArrayList<String>());
        }
        mSearchToEntity.get(entityName).add(entityId);
      }
    }
  }