logo separator

[mkgmap-dev] RoadDef patch

From Gerd Petermann gpetermann_muenchen at hotmail.com on Thu Nov 6 08:34:15 GMT 2014

Hi Brian,

thanks for the patch. If I got it right, the compareTo() methid is obsolete
as we do no longer sort RoadDef instances anywhere. So,
it would be easier to remove the Comparable attribute from the class
public class RoadDef /*implements Comparable<RoadDef>*/ {
and remove the compareTo() method.

You are right regarding the hashCode() method, but I think
we should not use the fields id + name to implement it.
A style may add the same OSM way as a routable line multiple times,
in that case these two fields are equal.

A typical map has less than 100.000 RoadDef instances, so I see no problem
to add an int (or long) field like roadId which is filled with a unique value
and use that in hashCode().
What do you think?

Gerd

From: brianegge at gmail.com
Date: Wed, 5 Nov 2014 22:28:38 -0500
To: mkgmap-dev at lists.mkgmap.org.uk
Subject: [mkgmap-dev] RoadDef patch

I’m not sure what the concurrency issue is related to this class, but it seems to have some problems around equality. First, it’s being used in a HashMap, which means both equals and hashCode need to be implemented. Second, the compareTo was using an unimplemented hashCode, which results in random sorting and inability to find two identical objects. 
 
I’m not sure I understand all the details of what RoadDef does, but I’ve fixed up the basic methods in the class to be consistent and added a test case around those methods. 
 

Brian
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev at lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20141106/945de5b5/attachment-0001.html>


More information about the mkgmap-dev mailing list