Tag Info

Hot answers tagged

11

Why is it confusing? The javadoc for HashMap.put clearly states: Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced. It clearly states what happens when you do a put with a key which was already in the map. The specific case of key == null behaves in the ...


10

This is a great fit for a map (2nd or 3rd proposed solution). I've used it dozens of times, and it's simple and effective. I don't really distinguish between these solutions; the important point is that there is a map with function names as the keys. The major advantage of the map approach, in my opinion, is that the table is data. This means that it can ...


9

map is a fairly well-rounded dictionary-type container that provides several advantages over std::list (linked lists) and std::vector (arrays). Although its not strictly specified, the performance constraints required on a map pretty much forces it to be implemented as some kind of self-balancing binary tree. So if its helpful to you to think about it in ...


8

http://gadm.org/ seems to have exactly what you want (and more). GADM database of Global Administrative Areas GADM is a spatial database of the location of the world's administrative areas (or adminstrative boundaries) for use in GIS and similar software. Administrative areas in this database are countries and lower level subdivisions such as ...


8

The definition from wikipedia seems correct and general enough: collection of unique keys and a collection of values, where each key is associated with one value (or set of values) Not a word about order. That should be perfectly fine, as there are many good ways to implement data structures that are perfect associative arrays, only without the ...


8

Hash functions are used to convert the input (usually string) to a smaller fixed length (typically) "hashed value" which typically is used somewhat like a array index for the hash table. Ideally this value should be evenly spread throughout its range, and avoid any obvious/significant concentrations. A hash function is any algorithm or subroutine that ...


5

An adapter strategy sounds good enough for this case, i.e., define a common interface and then proceed to implement that interface for each provider. The choice for which map provider to use can be a configurable option in the settings. Also see Mapstraction, a JavaScript library that provides a common interface for several map providers, including Google, ...


4

The Google Maps API licensing page explains this fairly well, to summarise, there are three types of license: Google Maps API The Google Maps API is a free service that lets you embed Google Maps in your freely accessible web pages or mobile apps. Your service must be freely and publicly accessible to end users. Google Maps API for Business Google ...


4

There is an implementation of MVC objects in Google Maps JavaScript API V3. It allows map objects to store state and update their presentation automatically. There is a DEMO of moving and resizing a circle which may provide what you require. The full tutorial can be seen HERE


4

What sort of data? Are you looking for map tiles? there are other websites providing services for providing map tiles such as openstreetmap (or mapquest) which provide images for maps and even data for geolocation for free. Alternatively you can also try services of cloudmade But when using other data such as tiles, you will have to use a different ...


4

The best way to approach this is to go to FP Complete's Hoogle and type in the signature you're looking for, (a -> Maybe b) -> [a] -> Maybe [b]. The first hit is a function called mapM which is exactly what you are looking for. In fact it works for all Monads, not just Maybe. (If you want to be even more general you can use traverse)


4

You want a function with this signature: (a -> Maybe b) -> [a] -> Maybe [b] Entering this into hoogle gives this possibility: Prelude mapM :: Monad m => (a -> m b) -> [a] -> m [b] A look at the Hackage documentation for mapM says it is the same as: mapM f = sequence . map f and that the definition of sequence is: sequence ...


3

Your problem lends very nicely to the Command design pattern. So basically you will have a base Command interface and then there would be multiple CommandImpl classes that would implement that interface. The interface essentially needs to just have a a single method doCommand(Args args). You can have the arguments passed in via an instance of Args class. ...


3

The decompiler probably has problems in decompiling class names correctly that contain a $ symbol. The symbol you are searching for is named Predef$: import scala.Predef; import scala.Predef$; import scala.Tuple2; import scala.collection.immutable.Map; import scala.collection.mutable.WrappedArray; public class T { @SuppressWarnings({ "rawtypes", ...


3

Fairly straightforward steps: Include boilerplate generic warnings, as you might see in many other pieces of software, and include them as part of a license agreement for users to agree to before they use your software Add a specific clause to the license agreement, informing users that you are not responsible for the map data that you're providing, and ...


3

I used to write pacman style games on the Spectrum as a kid. A 2d array is perfectly adequate, all you need is a value for wall, a value for road and a value for road with dot on. Your position is x,y, you can decide whether you can move, or eat a dot by interrogating the cells around. A common tip is to create a fake wall around the map so you don't have ...


3

It seems to me that the main issue is only including nodes that add significant information about a road. i.e. without your GPS requirement, you could just store nodes at junctions and endings (which I think you call start/end nodes). Obviously including weight/costs etc. One way I can think of approaching this is to first, add all start/end nodes. This is ...


3

For most purposes the classes from the standard library are likely to outperform any quickly-put-together data structure / container / algorithm you will write. This is assuming you choose the right abstraction (std::vector and std::list have different trade-offs, for example). A lot of time and effort by a lot of smart people has gone into making those ...


3

Data from Google is based on multiple sources: Photos of earth from satellites, Closer, more detailed photos from airplanes, Photos done by cars, bicycles, etc. done for street view, Geolocation data from smartphones, especially important for traffic view, etc. Having all those different types of data allows not only to reduce errors, but also create, ...


2

This will require you to access some database(s) which hold maximum allowed speeds for each road. Looking to purchase such information can turn out to be quite costly, especially if you want to cover wide areas. Combining several different data sources can also result in some extra required effort. Probably it's best to use an existing service, like Google ...


2

If you're really worried - talk to an insurance agent about an 'errors and omissions' policy - I didn't say buy one, just talk to them - you'll probably learn a lot and its cheaper than a lawyer - which, as previous posters observed, you're gonna need


2

I am not aware of any mapping libraries that support highlights outright but if you want to do this with Google Maps or Yahoo GeoService then you can simply record the latitude and longitude of the bounds of the highlight area in a database. On loading the map again, you can restore the highlight area from those bounds by rendering points using the ...


2

Yes, you can definately do this with OSM. Where to start: Whenever i am looking for something i haven't done with it yet, i go back browsing the examples page for something suitable. Then i look at the code and try to understand how it works by extending it or copying parts of it (maybe just to understand a certain feature better). This is the other page ...


2

As far as I know, usage of Google Maps for desktop apps is forbidden. (Scratch that, it's now OK, so long as it's a publicly available and downloadable app - will rewrite this answer.) If you want this to run within a native desktop application - and not in a normal brower connecting to a web-app, though that could also be one way of doing it - you'll need ...


2

If you're using Python 2.x, then that's easily achievable by using cmp, although you have to modify your function to return -1 instead of 0. Something like this: def greater(a, b): if (a % b) % 2 == 0: return 1 return -1 x = [2,7,5,10,30,15] print(sorted(x, cmp=greater)) But if you're using Python 3.x, then it gets a bit more complicated ...


2

Well, you're no longer dependent on the order of the columns in the data, but you're now dependent on the column names. If someone adds a column to an extract, even if it's in the middle, you're better off, because your code won't break. If someone deletes or renames a column, you'll still have an issue. If it's more likely that someone will rename a ...


2

Whenever I find myself asking whether I should use a switch statement or OO-style polymorphism I refer to the Expression Problem. Basically, if you have different "cases" for your data and wand to support different "actions" (where each action does something different for each case) then its really hard to make a system that naturally lets you add both new ...


2

Google said in 2012 we will begin adding 3D models to entire metropolitan areas to Google Earth on mobile devices. This is possible thanks to a combination of our new imagery rendering techniques and computer vision that let us automatically create 3D cityscapes, complete with buildings, terrain and even landscaping, from 45-degree aerial ...


2

I'm not sure about the programming/algorithm side, but they are using aircraf to collect data at a 45 degree angle. I assume, they can interpolate object size based on comparison of one photo top down, and the 45 degree angle photo. Just a guess. See here: http://www.reuters.com/article/2012/06/06/google-maps-idUSL1E8H6FCX20120606


2

It seems that you want to do polygon rasterization, where your "pixels" are your grid elements. An approach I would try (as chances are you will find ready-to-use algorithms to do that), is to use an in-memory rasterizer (e.g. Cairo), adjusting the filtering (and of course the coordinates of your polygons so they are expressed in grid units). You could ...



Only top voted, non community-wiki answers of a minimum length are eligible