diff --git a/src/org/oscim/generator/TileGenerator.java b/src/org/oscim/generator/TileGenerator.java index 3ea673c4..8776274f 100644 --- a/src/org/oscim/generator/TileGenerator.java +++ b/src/org/oscim/generator/TileGenerator.java @@ -23,7 +23,6 @@ import org.oscim.database.IMapDatabase; import org.oscim.database.IMapDatabaseCallback; import org.oscim.database.QueryResult; import org.oscim.renderer.MapTile; -import org.oscim.renderer.WayDecorator; import org.oscim.renderer.layer.ExtrusionLayer; import org.oscim.renderer.layer.Layer; import org.oscim.renderer.layer.Layers; diff --git a/src/org/oscim/renderer/WayDecorator.java b/src/org/oscim/generator/WayDecorator.java similarity index 55% rename from src/org/oscim/renderer/WayDecorator.java rename to src/org/oscim/generator/WayDecorator.java index 509ee6d8..0c3abe36 100644 --- a/src/org/oscim/renderer/WayDecorator.java +++ b/src/org/oscim/generator/WayDecorator.java @@ -1,5 +1,6 @@ /* * Copyright 2010, 2011, 2012 mapsforge.org + * Copyright 2013, OpenScienceMap * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -12,91 +13,13 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.renderer; +package org.oscim.generator; import org.oscim.core.Tile; import org.oscim.renderer.layer.TextItem; import org.oscim.theme.renderinstruction.Text; public final class WayDecorator { - // /** - // * Minimum distance in pixels before the symbol is repeated. - // */ - // private static final int DISTANCE_BETWEEN_SYMBOLS = 200; - - // /** - // * Minimum distance in pixels before the way name is repeated. - // */ - private static final int DISTANCE_BETWEEN_WAY_NAMES = 100; - - // /** - // * Distance in pixels to skip from both ends of a segment. - // */ - // private static final int SEGMENT_SAFETY_DISTANCE = 30; - - // static void renderSymbol(Bitmap symbolBitmap, boolean alignCenter, - // boolean repeatSymbol, float[][] coordinates, - // List waySymbols) { - // int skipPixels = SEGMENT_SAFETY_DISTANCE; - // - // // get the first way point coordinates - // float previousX = coordinates[0][0]; - // float previousY = coordinates[0][1]; - // - // // draw the symbol on each way segment - // float segmentLengthRemaining; - // float segmentSkipPercentage; - // float symbolAngle; - // for (int i = 2; i < coordinates[0].length; i += 2) { - // // get the current way point coordinates - // float currentX = coordinates[0][i]; - // float currentY = coordinates[0][i + 1]; - // - // // calculate the length of the current segment (Euclidian distance) - // float diffX = currentX - previousX; - // float diffY = currentY - previousY; - // double segmentLengthInPixel = Math.sqrt(diffX * diffX + diffY * diffY); - // segmentLengthRemaining = (float) segmentLengthInPixel; - // - // while (segmentLengthRemaining - skipPixels > SEGMENT_SAFETY_DISTANCE) { - // // calculate the percentage of the current segment to skip - // segmentSkipPercentage = skipPixels / segmentLengthRemaining; - // - // // move the previous point forward towards the current point - // previousX += diffX * segmentSkipPercentage; - // previousY += diffY * segmentSkipPercentage; - // symbolAngle = (float) Math.toDegrees(Math.atan2(currentY - previousY, - // currentX - previousX)); - // - // waySymbols.add(new SymbolContainer(symbolBitmap, previousX, previousY, - // alignCenter, symbolAngle)); - // - // // check if the symbol should only be rendered once - // if (!repeatSymbol) { - // return; - // } - // - // // recalculate the distances - // diffX = currentX - previousX; - // diffY = currentY - previousY; - // - // // recalculate the remaining length of the current segment - // segmentLengthRemaining -= skipPixels; - // - // // set the amount of pixels to skip before repeating the symbol - // skipPixels = DISTANCE_BETWEEN_SYMBOLS; - // } - // - // skipPixels -= segmentLengthRemaining; - // if (skipPixels < SEGMENT_SAFETY_DISTANCE) { - // skipPixels = SEGMENT_SAFETY_DISTANCE; - // } - // - // // set the previous way point coordinates for the next loop - // previousX = currentX; - // previousY = currentY; - // } - // } public static TextItem renderText(float[] coordinates, String string, Text text, int pos, int len, TextItem textItems) { @@ -105,7 +28,7 @@ public final class WayDecorator { // calculate the way name length plus some margin of safety float wayNameWidth = -1; float minWidth = Tile.TILE_SIZE / 10; - int skipPixels = 0; + //int skipPixels = 0; // get the first way point coordinates int prevX = (int) coordinates[pos + 0]; @@ -179,10 +102,12 @@ public final class WayDecorator { float segmentLength = (float) Math.sqrt(vx * vx + vy * vy); - if (skipPixels > 0) { - skipPixels -= segmentLength; + //if (skipPixels > 0) { + // skipPixels -= segmentLength; + // + //} else - } else if (segmentLength < minWidth) { + if (segmentLength < minWidth) { // restart from next node prevX = (int) coordinates[i]; prevY = (int) coordinates[i + 1]; @@ -201,14 +126,13 @@ public final class WayDecorator { } //float s = (wayNameWidth + 20) / segmentLength; - float s; - + //float s; //if (wayNameWidth < segmentLength) // s = (segmentLength - 10) / segmentLength; //else - s = (wayNameWidth + 20) / segmentLength; + //s = (wayNameWidth + 20) / segmentLength; + //float width, height; - float width, height; float x1, y1, x2, y2; if (prevX < curX) { @@ -223,16 +147,16 @@ public final class WayDecorator { y2 = prevY; } -// // estimate position of text on path -// width = (x2 - x1) / 2f; -// //width += 4 * (width / wayNameWidth); -// x2 = x2 - (width - s * width); -// x1 = x1 + (width - s * width); -// -// height = (y2 - y1) / 2f; -// //height += 4 * (height / wayNameWidth); -// y2 = y2 - (height - s * height); -// y1 = y1 + (height - s * height); + //// estimate position of text on path + //width = (x2 - x1) / 2f; + ////width += 4 * (width / wayNameWidth); + //x2 = x2 - (width - s * width); + //x1 = x1 + (width - s * width); + // + //height = (y2 - y1) / 2f; + ////height += 4 * (height / wayNameWidth); + //y2 = y2 - (height - s * height); + //y1 = y1 + (height - s * height); TextItem n = TextItem.get(); @@ -257,8 +181,6 @@ public final class WayDecorator { t.next = items; items = t; - skipPixels = DISTANCE_BETWEEN_WAY_NAMES; - // skip to last i = last; // store the previous way point coordinates