|
Replies:
8
-
Pages:
1
-
Last Post:
23 Nov 22, 21:27
Last Post By: MarkusD
|
|
|
Posts:
727
Registered:
13-Apr-2006
|
|
|
Make OSM file.groovy find title/comment with "
Posted:
20 Nov 22, 17:20
|
|
|
|
Hi Rob,
I try to identify titles and comments which have a " included, because this will result in a non working points.js file. I tried to solve that by myself, to no avail. Please help.
// Check for " in title
if ao.getTitle().indexOf('"') != -1 {
if (debug) System.out.println("\" found for [" + name + "] in title");
}
// Check for " in comment
if ao.getComment().indexOf('"') != -1 {
if (debug) System.out.println("\" found for [" + name + "] in comment");
}
Thanks in advance.
Attached my modified file so far.
|
|
|
Posts:
4,092
Registered:
4-Aug-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
20 Nov 22, 19:54
in response to: MarkusD
|
 |
Helpful |
|
|
|
I can't remember if there was a reason not to use HTML entities, so try the attached.
Using the last released file, lines 130 and 131 now have (a space added after the & to show the code for a quote.
pointsTxt += "\t\t\"t\": \"" + ao.getTitle().replaceAll("\"","& quot;").replaceAll("'","'") + "\",\n";
pointsTxt += "\t\t\"c\": \"" + ao.getComment().replaceAll("\"","& quot;").replaceAll("'","'") + "\",\n";
|
|
|
Posts:
8,090
Registered:
31-Jan-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
20 Nov 22, 20:40
in response to: MarkusD
|
 |
Helpful |
|
|
Java, and, by extension, Groovy, can be very fussy about single and double quotes. Single quotes are used to define a character, whereas double quotes are used to define a String.
The test you probably want is: if(ao.getTitle().contains("\"")) {
do something;
}
|
|
|
Posts:
727
Registered:
13-Apr-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
21 Nov 22, 20:14
in response to: JeffTucker
|
|
|
Hi Jeff,
yes, that code did what I was after. Thanks.
|
|
|
Posts:
727
Registered:
13-Apr-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
21 Nov 22, 20:18
in response to: RobM
|
|
|
|
Hi Rob,
the aim is not to correct comments or titles with quotes. Because it will not "heal" something like this:
<a href="https://goo.gl/maps/cE8cKUH4WA92" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Karte</a>
So what I try is to identify the objects with quotes and correct them in the first place. Anyway, Rob, thanks for your support.
Attached the actual file.
|
|
|
Posts:
4,092
Registered:
4-Aug-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
22 Nov 22, 09:10
in response to: MarkusD
|
|
|
The title and comment text could have all html tags removed, instead of manually editing the file. It would remove bold, italic, paragraph too.
|
|
|
Posts:
727
Registered:
13-Apr-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
22 Nov 22, 19:34
in response to: RobM
|
|
|
The title and comment text could have all html tags removed, instead of manually editing the file. It would remove bold, italic, paragraph too.
Rob, that sounds very nice, but I would like to keep all html tags as they are. And this is no problem at all. This is one of the more complex comments I have: points = [{
"l": [62.068633,9.125700],
"dt": "09.12.2011 01:00",
"t": "Bergen – Trondheim",
"c": "Überblick über die Tour des Tages<br>Freitag: … <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Floro/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Florø</a>, <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Maloy/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Måløy</a>, <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Torvik/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Torvik</a>, <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Alesund/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Ålesund</a>, Ålesund - Åndalsnes, <a href='http://www.nsb.no/stasjoner_uaa/aandalsnes-stasjon-article24943-2676.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Åndalsnes</a> - <a href='http://www.nsb.no/stations_df/dombaas-station-article25230-2768.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Dombås</a>, <a href='http://www.nsb.no/stations_df/dombaas-station-article25230-2768.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Dombås</a> - <a href='http://www.nsb.no/stasjoner_st/trondheim-stasjon-article25018-2675.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Trondheim</a>, …",
"f": "Google%20Maps%20-%20Opera.jpg",
"ca": "0"
}
Works perfectly well.
So with my addition to "OSM file.groovy" I'm able to find out which comments still have quotes. I change the quotes to ' in my comment, create the point-js files again, and I'm done.
|
|
|
Posts:
4,092
Registered:
4-Aug-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
22 Nov 22, 20:51
in response to: MarkusD
|
|
|
|
So with my addition to "OSM file.groovy" I'm able to find out which comments still have quotes. I change the quotes to ' in my comment, create the point-js files again, and I'm done.
The attached will convert titles and comments with double quotes to single quotes.
If your comment is Überblick über die Tour des Tages<br>Freitag: … <a href="http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Floro/" style="color:#00CCFF;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Florø</a>, <a href="http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Maloy/" style="color:#00CCFF;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Måløy</a>, <a href="http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Torvik/" style="color:#00CCFF;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Torvik</a>, <a href="http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Alesund/" style="color:#00CCFF;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Ålesund</a>, Ålesund - Åndalsnes, <a href="http://www.nsb.no/stasjoner_uaa/aandalsnes-stasjon-article24943-2676.html" style="color:#FFFF99;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Åndalsnes</a> - <a href="http://www.nsb.no/stations_df/dombaas-station-article25230-2768.html" style="color:#FFFF99;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Dombås</a>, <a href="http://www.nsb.no/stations_df/dombaas-station-article25230-2768.html" style="color:#FFFF99;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Dombås</a> - <a href="http://www.nsb.no/stasjoner_st/trondheim-stasjon-article25018-2675.html" style="color:#FFFF99;text-align:left" target="_blank" class="mylink" rel="noreferrer noopener nofollow">Trondheim</a>, …
The points.js will become "c": "Überblick über die Tour des Tages<br>Freitag: … <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Floro/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Florø</a>, <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Maloy/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Måløy</a>, <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Torvik/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Torvik</a>, <a href='http://www.hurtigruten.de/norwegen/Postschiffreisen/Reiseprogramme-2012/Hafen/Alesund/' style='color:#00CCFF;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Ålesund</a>, Ålesund - Åndalsnes, <a href='http://www.nsb.no/stasjoner_uaa/aandalsnes-stasjon-article24943-2676.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Åndalsnes</a> - <a href='http://www.nsb.no/stations_df/dombaas-station-article25230-2768.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Dombås</a>, <a href='http://www.nsb.no/stations_df/dombaas-station-article25230-2768.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Dombås</a> - <a href='http://www.nsb.no/stasjoner_st/trondheim-stasjon-article25018-2675.html' style='color:#FFFF99;text-align:left' target='_blank' class='mylink' rel='noreferrer noopener nofollow'>Trondheim</a>, …",
No need to manually change anything, apart from malformed HTML
If I have (again) misunderstood just ignore the attached.
|
|
|
Posts:
727
Registered:
13-Apr-2006
|
|
|
Re: Make OSM file.groovy find title/comment with "
Posted:
23 Nov 22, 21:19
in response to: RobM
|
|
|
Thanks Rob for the enhancements. I saved your code in my file, as a comment. I'm not sure if it makes sense for me to use it. I'm still in the process to check if all of my produced points.js files work.
Right now I try to add another feature to it. It does work quite well but I might come back with another question.
Thanks again.
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|