I'm trying to draw maps similar to these in Java:
I want to auto-generate them from a list of pairs (country,color) to determine the colors. Or (state,color) in the US case. I presume there must be common ways for this, as I find several websites generating them on the fly and sites like wikipedia have several which look exactly the same. But I fail to find information on how to actually generate them. How can I do this?
Related
I'm developing a navigation application for android. I need to convert the floor map into a hierarchical graph. As far as I know after converting the map into a graph this will produce an XML file presenting the rooms as nodes. I have searched about hierarchical graph but all I got was theoretical explanation of the graphs.
While searching also I read something about GoogleOpenStreet. I read that it can be used to convert floor plans into graphs but also I didn't find anything about how to do it.
Can anyone suggest methods to do this using Java?
Since I found a solution, and no one answered it. I will answer it to help other people who have the same problem.
I didn't find a direct method to convert floor plans into hierarchical graphs, instead I used a graph editor to draw a graph that represent the floor plan and then used the resulting file ( which is similar to XML format) and parsed in.
I'm in the process of making a swimlane diagram but can't come up with a good algorithm to automatically lay out the lines that connect the nodes in the diagram. What I essentially want is this.
However, I don't have any protection against lines overlapping or intersecting right now and it sometimes gets very messy.
Does anyone know a way to detect if a line will intersect ANY of the lines already drawn?
One idea that I've come up with is to store the paths in an array or table and check the entire table every time a new line is slated to be drawn but that does not seem efficient.
I'm doing this in javascript and java through the use of GWT so maybe there is an easy way to solve this using one of the tools provided by these languages?
If your real issue is to minimize the line intersections, there are several algorithms that try to accomplish this in diagrams. Check this link for example, there are also more algorithms that are used in auto routing for electric design automation that are also used in this kind of diagrams, like Lee algorithm, or A* Algorithm.
I don't know if the tools that you are using have enough flexibility to implement this kind of algorithms, usually you need to implement your own heuristic according to the specific type of diagram, but I hope that this links are enough to give you good ideas.
Minimizing the line intersections in a graph is a difficult NP-Hard problem, check this link (about the crossing number) for more information.
Good luck.
I actually am trying to find the distance between two places, I am new to this. I came to know about openstreetmap. But I am not sure what to do.
I found a traveling salesman application that uses osm to route.
But here my question is how to get a osm between places .e.g. "http://www.openstreetmap.org/api/0.6/map?bbox=10,30,10,30" this gives me the map of the box (10,30,10,30) .. but if I want to get the map between leeds and sheffield what should be my query.
Or is there any other way to find the distance.(As I am a student I want some open source way for my academic project..)
please suggest..
You should consider implementing this by yourself.
First, I suggest you to use the Overpass API to do your queries.
Then implement this algorithm over the ways you get from the Overpass API :)
For calculating the routing distance between two places you can use one of the various online or offline routers. There is also a list of various information for routing developers containing a list of libraries and other information.
If you have to obtain the location of a specific address before doing the actual routing you can use Nominatim.
Is there any Java library with TreeMap-like data structure which also supports all of these:
lookup by value (like Guava's BiMap)
possibility of non-unique keys as well as non unique values (like Guava's Multimap)
keeps track of sorted values as well as sorted keys
If it exists, it would probaby be called SortedBiTreeMultimap, or similar :)
This can be produced using a few data structures together, but I never took time to unite them in one nice class, so I was wondering if someone else has done it already.
I think you are looking for a "Graph". You might be interested in this slightly similar question asked a while ago, as well as this discussion thread on BiMultimaps / Graphs. Google has a BiMultimap in its internal code base, but they haven't yet decided whether to open source it.
I'm looking for several methods to compare two images to see how similar they are. Currently I plan to have percentages as the 'similarity index' end-result. My program outline is something like this:
User selects 2 images to compare.
With a button, the images are compared using several different methods.
At the end, each method will have a percentage next to it indicating how similar the images are based on that method.
I've done a lot of reading lately and some of the stuff I've read seems to be incredibly complex and advanced and not for someone like me with only about a year's worth of Java experience. So far I've read about:
The Fourier Transform - im finding this rather confusing to implement in Java, but apparently the Java Advanced Imaging API has a class for it. Though I'm not sure how to convert the output to an actual result
SIFT algorithm - seems incredibly complex
Histograms - probably the easiest out of all mentioned so far
Pixel grabbing - seems viable but if theres a considerable amount of variation between the two images it doesn't look like it's going to produce any sort of accurate result. I might be wrong?
I also have the idea of pre-processing an image using a Sobel filter first, then comparing it. Problem is the actual comparing part.
So yeah I'm looking to see if anyone has ideas for comparing images in Java. Hoping that there are people here that have done similar projects before. I just want to get some input on viable comparison techniques that arent too hard to implement in Java.
Thanks in advance
Fourier Transform - This can be used to efficiently can compute the cross-correlation, which will tell you how to align the two images and how similar they are, when they are optimally aligned.
Sift descriptors - These can be used to compare local features. They are often used for correspondence analysis and object recognition. (See also SURF)
Histograms - The normalized cross-correlation often yields good results for comparing images on a global level. But since you are just comparing color distributions you could end up declaring an outdoor scene with lots of snow as similar to an indoor scene with lots of white wallpaper...
Pixel grabbing - No idea what this is...
You can get a good overview from this paper. Another field you might to look into is content based image retrieval (CBIR).
Sorry for not being Java specific. HTH.
As a better alternative to simple pixel grabbing, try SSIM. It does require that your images are essentially of the same object from the same angle, however. It's useful if you're comparing images that have been compressed with different algorithms, for example (e.g. JPEG vs JPEG2000). Also, it's a fairly simple approach that you should be able to implement reasonably quickly to see some results.
I don't know of a Java implementation, but there's a C++ implementation using OpenCV. You could try to re-use that (through something like javacv) or just write it from scratch. The algorithm itself isn't that complicated anyway, so you should be able to implement it directly.