0

I am seeking help on the exact procedures on setting up the 0.3.0 mapsforge library. I have downloaded ALL the required classes from the 0.3.0 branch here, but I am having a problem where I am unsure how to set up the resources for the rendering. Below is my logcat error:

03-30 17:02:23.475: E/DatabaseRenderer(17312): org.xml.sax.SAXException: No input specified.
03-30 17:02:23.475: E/DatabaseRenderer(17312):  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:288)
03-30 17:02:23.475: E/DatabaseRenderer(17312):  at org.mapsforge.android.maps.rendertheme.RenderThemeHandler.getRenderTheme(RenderThemeHandler.java:77)
03-30 17:02:23.475: E/DatabaseRenderer(17312):  at org.mapsforge.android.maps.mapgenerator.databaserenderer.DatabaseRenderer.getRenderTheme(DatabaseRenderer.java:66)
03-30 17:02:23.475: E/DatabaseRenderer(17312):  at org.mapsforge.android.maps.mapgenerator.databaserenderer.DatabaseRenderer.executeJob(DatabaseRenderer.java:149)
03-30 17:02:23.475: E/DatabaseRenderer(17312):  at org.mapsforge.android.maps.mapgenerator.MapWorker.doWork(MapWorker.java:73)
03-30 17:02:23.475: E/DatabaseRenderer(17312):  at org.mapsforge.android.maps.PausableThread.run(PausableThread.java:94)

I'm really confused as it seems to be from this line in DatabaseRenderer:

private static RenderTheme getRenderTheme(JobTheme jobTheme) {
    InputStream inputStream = null;
    try {
        inputStream = jobTheme.getRenderThemeAsStream(); //THIS LINE

which gets even more confusing when I look at the jobTheme class:

public interface JobTheme extends Serializable {
/**
 * @return an InputStream to read the render theme data from.
 * @throws FileNotFoundException
 *             if the render theme file cannot be found.
 */
    InputStream getRenderThemeAsStream() throws FileNotFoundException;
}

I'm very lost on how to debug this as the method as an interface class's method. Thus how is it even possible to call it with a jobTheme object?

Would appreciate any help for this, thanks!

4

1 回答 1

0

我集成了一个地图伪造瓷砖提供者(用作谷歌地图覆盖中的离线地图),我遇到了类似的问题。内置的InternalRenderTheme.OSMARENDER只是无法正常工作。

这就是我最终做的事情:

/**
 * For some reason, if we just use InternalRenderTheme.OSMARENDER, it fails to work (the XML parser gets a NULL
 * as the input stream).  It must be something to do with class loading in dependent libraries.
 * Anyway, this code properly opens the resource in the MapsForge jar as an input stream.
 */
static private class RenderTheme implements JobTheme
{
    static private final String path = "/org/mapsforge/android/maps/rendertheme/osmarender/osmarender.xml";

    @Override
    public InputStream getRenderThemeAsStream()
    {
        return getClass().getResourceAsStream(path);
    }
}

然后我在初始化我的 tile 提供程序时进行了设置:

mapGenerator = new DatabaseRenderer();
mapDatabase = new MapDatabase();
mapGenerator.setMapDatabase(mapDatabase);

jobParameters = new JobParameters(new RenderTheme(), DEFAULT_TEXT_SCALE);

我希望这有帮助。

于 2013-08-07T20:59:27.450 回答