tillnagel / unfolding

A library to create interactive maps and geovisualizations in Processing and Java
http://unfoldingmaps.org
Other
478 stars 245 forks source link

Template with examples not working #167

Open Amoranemix opened 5 years ago

Amoranemix commented 5 years ago

Dear Github members,

I have started a course on Object Oriented programming in Java from UCSD via the Coursera platform and using Eclipse. (I am not familiar with Eclipse.) The exercises are based on Unfolding Maps. The teachers made a starter program that we are supposed to extend , but that doesn't work. The reason seems to be that their program uses the no longer supported AppletViewer.

I decided to try out Unfolding Maps myself in the hope of learning how to modify the starter program from UCSD such that it works. So I downloaded unfolding_app_template_with_examples_0.9.6.zip and imported it in Eclipse.

I tried JDK 1.8 and 12. Running the first example, SimpleMapApp failed with both. With JDK 12, running as Java applet, the following error message is displayed in the console :

Error: Could not find or load main class sun.applet.AppletViewer
Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer

Running as Java application, an empty map window appears and the following message in the console :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/C:/Users/Frank%20Tavernier/Documents/School/eclipse-workspace/unfolding-app-template-with-examples/lib/gluegen-rt.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Unfolding Map v0.9.6
Using OpenGLMapDisplay with processing.opengl.PGraphics2D
server.org/tiles/bw-mapnik/10/549/336.png contains bad image data, or may not be an image.
The file http://a.www.toolserver.org/tiles/bw-mapnik/10/550/336.png contains bad image data, or may not be an image.
The file http://a.www.toolserver.org/tiles/bw-mapnik/10/549/335.png contains bad image data, or may not be an image.
The file http://a.www.toolserver.org/tiles/bw-mapnik/10/548/335.png contains bad image data, or may not be an image.
The file http://a.www.toolserver.org/tiles/bw-mapnik/10/548/336.png contains bad image data, or may not be an image.

+about 30 more similar lines

Can anyone explain how to make Unfolding Map work with Eclipse ?

tillnagel commented 5 years ago

Please try out the latest beta at http://services.informatik.hs-mannheim.de/~nagel/GDV/unfolding_app_template_with_examples_0.9.92.zip

Amoranemix commented 5 years ago

Thanks for the suggestion.

I imported that new version. When running the first example, HellowUnfoldingWorld.java, with JDK 12, the console displays :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/C:/Users/Frank%20Tavernier/Documents/School/eclipse-workspace/unfolding-app-template-with-examples/lib/gluegen-rt.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Unfolding Map v0.9.92
Using OpenGLMapDisplay with processing.opengl.PGraphics2D

A window opens that displays black. I suspect it is supposed to display a map.

I haven't set the native library as instructed in the readme because I don't know how to do that.

tillnagel commented 5 years ago

Could you try Java 1.8 again?

Amoranemix commented 5 years ago

Running HelloUnfoldingWorld.java under JDK 1.8 does the same, except that there are no warnings.

tillnagel commented 5 years ago

Is this HelloUnfoldingWorld example app the one from the distribution (i.e. from the Unfolding project), or one from the UCSD course? Please use the one from the distribution, or paste the code here.

Amoranemix commented 5 years ago

It is an example from the package that I downloaded from the link you posted, version 0.9.92.

tillnagel commented 5 years ago

Ok, try out the SatelliteProviderMapApp to check if are able to see a map there.

Do you have a firewall prohibiting outgoing requests (the map tile images are requested from external servers).

Amoranemix commented 5 years ago

No. Running SatelliteProviderMapApp.java also shows a window that is filled with black, both under JDK 1.8 and 12.

As firewalls I have a router and Windows 10 Defender. I have had no problems with them since I have this computer, that is since 14 months ago. Temporarily disabling the latter appears to make no difference.

Amoranemix commented 5 years ago

If I understand correctly, there is no good way to use Unfolding Maps, at least not on my computer.

tillnagel commented 5 years ago

Yes, seems like it. I am very sorry for that, but haven't heard of your problem before.

Last question: Did you try other OpenGL examples (from Processing and/or JOGL)? Do any of these examples work on your computer?

Amoranemix commented 5 years ago

No. How can I find these other OpenGL examples from Processing and/or OpenGL ?

tillnagel commented 5 years ago

See e.g. https://processing.org/tutorials/p3d/

Amoranemix commented 5 years ago

I downloaded and installed Processing, which to my surprise was easy. Then I pasted the following code in the top of 2 windows :

float x,y,z; void setup() { size(200,200,P3D); x = width/2; y = height/2; z = 0; } void draw() { translate(x,y,z); rectMode(CENTER); rect(0,0,100,100); z++; // The rectangle moves forward as z increments. }

Then I told Processing to run that code and to my surprise it did. A window with a changing rectangle appeared. Warnings nor error messages appeared.

I tried using that code in Eclipse, but it tells me there are syntax errors in the code, like “P3D cannot be resolved to a variable”.

r-hmn commented 5 years ago

Hi. I also used that version 0.9.92 yesterday, using IntellJ, using JDK 1.8. the SimpleMapApp needed a small change wrt using size() to adhere to the processing.org 3.0 style. I also set it to use JAVA2D instead of OPENGL.

package de.fhpotsdam.unfolding.examples;

import processing.core.PApplet;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.utils.MapUtils;

/**
 * An application with a basic interactive map. You can zoom and pan the map.
 */
public class SimpleMapApp extends PApplet {

    UnfoldingMap map;

    public void settings() {
        size(800, 600, JAVA2D);
    }

    public void setup() {
        map = new UnfoldingMap(this);
        map.zoomAndPanTo(10, new Location(52.5f, 13.4f));
        MapUtils.createDefaultEventDispatcher(this, map);
    }

    public void draw() {
        map.draw();
    }

    public static void main(String args[]) {
        PApplet.main(new String[] { SimpleMapApp.class.getName() });
    }
}

This does show up for me.

Amoranemix commented 5 years ago

@ r-hmn: Using Eclipse, in the code of SimpleMapApp.java of the unfolding-app-template-with-examples package I replaced P2D with JAVA2D. I don't understand the other modification you suggested.

With that single change the program creates an interactive map showing Berlin.

I went back to my original problem with the UCSDUnfoldingMaps package and managed to make that work too with JDK 1.8 and JAVA2D as argument for size() i.s.o. P2D.

In the console the comment “No OpenGL renderer. Using Java2DMapDisplay.” appears when either program is run.

rochanofa commented 4 years ago

I also tried to run the "SimpleMapApp" in Eclipse but this exception message always appears:

Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at processing.core.PApplet.(PApplet.java:118)

I have no experience with Eclipse. Could anyone tell me what should I modify?

Isurumax26 commented 4 years ago

type following inside the HelloWorld class and Run as a Java application. It worked fine for me.

public static void main (String[] args) {

PApplet.main(module1.HelloWorld.class.getName());

}

hiralshah265 commented 4 years ago

Ok, try out the SatelliteProviderMapApp to check if are able to see a map there.

Do you have a firewall prohibiting outgoing requests (the map tile images are requested from external servers).

Thanks for this. For me the issue is RESOLVED here. It was due to my firewall blocking the images being loaded.