Bug #509

gmt2kml style names not unique when building overlays

Added by Paul over 3 years ago. Updated about 3 years ago.

Status:ClosedStart date:2014-02-10
Priority:NormalDue date:
Assignee:Paul% Done:

0%

Category:-
Target version:Candidate for next bugfix release
Affected version:all Platform:

Description

gmt2kml uses simple running numbers to create style ID tags, i.e., st0, st1, ... But when another gmt2kml layer is produced the numbering repeats, resulting in duplicate style definitions in the combined KML file. The solution might be to either pass the previous highest ID number via gmt.history or use more unique style names that combines a running number, the color and pen width and other attributes as part of the style name, e.g.

style-point-orange-penwidth-runningnumber

That should prevent styles with different settings from getting the same tag.

Associated revisions

Revision 12885
Added by Paul over 3 years ago

Generate style ID based on process ID in gmt2kml to ensure uniqueness, see issue #509

Revision 12897
Added by Paul over 3 years ago

Address change for issue #509

History

#1 Updated by Joaquim over 3 years ago

We could use time as ID. Say, number of seconds from beginning of year plus the running number. It would get something like:
thisRunStartTime_runningNumbers
But a potential problem raises if in an script the first layer is so fast to write that next layer would get the same "thisRunStartTime"

#2 Updated by Joaquim over 3 years ago

Or even simpler. Just a random number with 5 or 6 decimal places (e.g. a la Matlabish)

n = 0;
sprintf('%d_%d', round(rand(1)*1e5), n++)

#3 Updated by Paul over 3 years ago

  • Status changed from New to Resolved

Implemented using getpid() which is a unique process ID. Other gmt2kml calls running in parallel or later will have different PID. In r12887 (GMT5) and r10203 (GMT4).

#4 Updated by Remko over 3 years ago

Paul wrote:

Implemented using getpid() which is a unique process ID. Other gmt2kml calls running in parallel or later will have different PID. In r12887 (GMT5) and r10203 (GMT4).

I don't think your eventual solution, adding n_colors to PID is a good solution, because the different layers can have different n_colors values, which will allow n_colors+PID to overlap again. Best is to add something to the name of the ID such that no clash with the colours can occur. So styles should be called "st<pid>" where <pid> is the process ID. (You can add some letters to the colour ID as well, if your care, but is not necessary).

#5 Updated by Remko over 3 years ago

Sorry, I was not very clear. In GMT4 both the styles for colors and those for lines are called GMT%d, where %d is a number. In GMT5 both styles are called st%d, where %d is a number. The default style may best be called def%d.

#6 Updated by Paul over 3 years ago

OK, I changed it to #st-<PID>-<index>. I don't like def because the code is simpler if the def is what happens when -C is not set and index is initialized to -4 and never changes. In r12897 GMT5) and r10206 (GMT4).

#7 Updated by Remko about 3 years ago

  • Status changed from Resolved to Closed

Works now as requested

Also available in: Atom PDF