mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Map: Compare precision against 4 not 0 [#792]
This commit is contained in:
parent
72051f4ce9
commit
316c6c6a58
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,12 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.mapSources; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
package gplx.xowa.xtns.mapSources;
|
||||
|
||||
import gplx.xowa.Xop_fxt;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Map_dd2dms_func_tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Example() {fxt.Test_parse_tmpl_str_test("{{#dd2dms: 14.58|precision=4}}" , "{{test}}" , "14° 34' 48"");}
|
||||
@Test public void Plus() {fxt.Test_parse_tmpl_str_test("{{#dd2dms: 14.58|precision=4|plus=pos}}" , "{{test}}" , "14° 34' 48" pos");}
|
||||
@Test public void Ws() {fxt.Test_parse_tmpl_str_test("{{#dd2dms: 14.58| precision = 4 | plus = pos }}" , "{{test}}" , "14° 34' 48" pos");}
|
||||
@Test public void Nested_pfunc() {fxt.Test_parse_tmpl_str_test("{{#dd2dms: 14.58|{{#if:2|precision=2}}}}" , "{{test|3}}" , "14° 34'");} // handle "{{#if:2|precision=2}}" -> "precision=2"
|
||||
@Test public void Nested_pfunc() {fxt.Test_parse_tmpl_str_test("{{#dd2dms: 14.58|{{#if:2|precision=2}}}}" , "{{test|3}}" , "14° 35'");} // handle "{{#if:2|precision=2}}" -> "precision=2"
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,9 +13,22 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.mapSources; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
package gplx.xowa.xtns.mapSources;
|
||||
|
||||
import gplx.Bry_;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Bry_find_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.Double_;
|
||||
import gplx.Err_;
|
||||
import gplx.Math_;
|
||||
import gplx.String_;
|
||||
import gplx.core.btries.Btrie_slim_mgr;
|
||||
import gplx.core.primitives.Byte_obj_val;
|
||||
import gplx.xowa.parsers.Xop_ctx;
|
||||
import gplx.xowa.parsers.tmpls.Xot_invk;
|
||||
|
||||
class Map_math {// REF.MW:MapSources_math.php
|
||||
private int word_idx_nsew;
|
||||
private double[] rv = new double[4];
|
||||
@ -74,7 +87,7 @@ class Map_math {// REF.MW:MapSources_math.php
|
||||
double angle = Math_.Abs_double(dec);
|
||||
double deg = Math_.Floor(angle);
|
||||
double min = (angle - deg) * 60;
|
||||
double sec = prec > 0
|
||||
double sec = prec > 4 // 2020-09-03|ISSUE#:792|precision check should be > 4 not > 0;PAGE:en.w:Huntington_Plaza
|
||||
? Math_.Round((min - Math_.Floor(min)) * 60, prec - 4)
|
||||
: Math_.Round((min - Math_.Floor(min)) * 60, 0)
|
||||
;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,11 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.pfuncs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*;
|
||||
import org.junit.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
package gplx.xowa.xtns.wbases.pfuncs;
|
||||
|
||||
import gplx.Bry_;
|
||||
import gplx.xowa.xtns.wbases.Wdata_wiki_mgr_fxt;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Wdata_pf_property__basic__tst {
|
||||
@Before public void init() {fxt.Init();} private final Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt();
|
||||
@Test public void String() {
|
||||
@Before public void init() {fxt.Init();} private final Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt();
|
||||
@Test public void String() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -25,7 +30,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
fxt.Test_parse("{{#property:p1}}", "a");
|
||||
fxt.Test_parse("{{#property:p2}}", "");
|
||||
}
|
||||
@Test public void Entity() {
|
||||
@Test public void Entity() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q2")
|
||||
.Add_label("en", "b")
|
||||
);
|
||||
@ -35,7 +40,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
);
|
||||
fxt.Test_parse("{{#property:p1}}", "b");
|
||||
}
|
||||
@Test public void Entity_fr() { // PURPOSE: non-English wiki should default to English label if non-English label not available; DATE:2013-12-19
|
||||
@Test public void Entity_fr() { // PURPOSE: non-English wiki should default to English label if non-English label not available; DATE:2013-12-19
|
||||
// set wiki to French
|
||||
fxt.Wiki().Wdata_wiki_lang_(Bry_.new_a7("fr"));
|
||||
|
||||
@ -52,7 +57,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
// parse; should get en label
|
||||
fxt.Test_parse("{{#property:p1}}", "b");
|
||||
}
|
||||
@Test public void Entity_missing() { // PURPOSE: wiki may refer to entity that no longer exists; EX: {{#property:p1}} which links to Q1, but p1 links to Q2 and Q2 was deleted; DATE:2014-02-01
|
||||
@Test public void Entity_missing() { // PURPOSE: wiki may refer to entity that no longer exists; EX: {{#property:p1}} which links to Q1, but p1 links to Q2 and Q2 was deleted; DATE:2014-02-01
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_entity_qid(1, 2)) // create wdata page Q1 with prop entity reference to Q2; note that Q2 is not created
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -60,7 +65,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", ""); // parse; get ""
|
||||
}
|
||||
@Test public void Time() {
|
||||
@Test public void Time() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_time(1, "2012-01-02 03:04:05"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -68,7 +73,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "30405 2 Jan 2012"); // NOTE: format is missing ":" b/c test does not init messages for html_wtr; DATE:2015-08-03
|
||||
}
|
||||
@Test public void Geodata() {
|
||||
@Test public void Geodata() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_geo(1, "6.789", "1.2345"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -76,7 +81,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "1°14'4.2"N, 6°47'20.4"E");
|
||||
}
|
||||
@Test public void Quantity__plus_minus__y() {
|
||||
@Test public void Quantity__plus_minus__y() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_quantity(1, "+1234", "1", "+1236", "+1232"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -84,7 +89,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "1,234±2");
|
||||
}
|
||||
@Test public void Quantity__plus_minus__n() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
|
||||
@Test public void Quantity__plus_minus__n() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_quantity(1, "+1234", "1", "+1234", "+1234"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -92,7 +97,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "1,234");
|
||||
}
|
||||
@Test public void Quantity__range() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
|
||||
@Test public void Quantity__range() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_quantity(1, "+1234", "1", "+1236", "+1233"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -100,7 +105,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "1,233-1,236");
|
||||
}
|
||||
@Test public void Quantity__long() { // PURPOSE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
|
||||
@Test public void Quantity__long() { // PURPOSE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_quantity(1, "+4321000000", "1", "4321000000", "4321000000"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -108,7 +113,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "4,321,000,000");
|
||||
}
|
||||
@Test public void Quantity__unit__entity() {// PURPOSE: get entity name; EX:{{#invoke:Wikidata|getUnits|P2386|FETCH_WIKIDATA}} PAGE:en.w:Arecibo_Observatory; DATE:2016-10-11
|
||||
@Test public void Quantity__unit__entity() {// PURPOSE: get entity name; EX:{{#invoke:Wikidata|getUnits|P2386|FETCH_WIKIDATA}} PAGE:en.w:Arecibo_Observatory; DATE:2016-10-11
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_quantity(1, "+1234", "http://www.wikidata.org/entity/Q2", "+1236", "+1232"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -121,7 +126,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "1,234±2 meter");
|
||||
}
|
||||
@Test public void Quantity__decimal() {
|
||||
@Test public void Quantity__decimal() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_quantity(1, "+1234.50", "1", "+1236.75", "+1232.25"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -129,7 +134,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "1,234.5±2.25");
|
||||
}
|
||||
@Test public void Monolingualtext() {
|
||||
@Test public void Monolingualtext() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_monolingual(1, "la", "Lorem ipsum dolor sit amet"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -137,7 +142,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "Lorem ipsum dolor sit amet");
|
||||
}
|
||||
@Test public void Novalue() {
|
||||
@Test public void Novalue() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_novalue(1))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -145,7 +150,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "no value");
|
||||
}
|
||||
@Test public void Somevalue() {
|
||||
@Test public void Somevalue() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_somevalue(1))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -153,7 +158,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "unknown value");
|
||||
}
|
||||
@Test public void Multiple() {
|
||||
@Test public void Multiple() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q1")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"), fxt.Make_claim_string(1, "b"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -161,7 +166,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1}}", "a"); // only take first; DATE:2015-08-02
|
||||
}
|
||||
@Test public void Q() {
|
||||
@Test public void Q() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q2")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -169,7 +174,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1|q=Q2}}", "a");
|
||||
}
|
||||
@Test public void Of() {
|
||||
@Test public void Of() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q2")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"))
|
||||
.Add_sitelink("enwiki", "Of_page")
|
||||
@ -177,7 +182,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1|of=Of_page}}", "a");
|
||||
}
|
||||
@Test public void From() {
|
||||
@Test public void From() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Property:P2")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"))
|
||||
);
|
||||
@ -186,7 +191,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
fxt.Test_parse("{{#property:p1|from=}}", "");
|
||||
fxt.Test_parse("{{#property:p1| from = P2 }}", "a"); // PURPOSE: trim ws; ISSUE#:361; DATE:2019-02-11
|
||||
}
|
||||
@Test public void Pid_as_name() {
|
||||
@Test public void Pid_as_name() {
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q2")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -195,7 +200,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:astronomic symbol}}", "a");
|
||||
}
|
||||
@Test public void Empty_arg() { // PURPOSE: {{#property:p1|}} should not fail / warn; DATE:2013-11-15
|
||||
@Test public void Empty_arg() { // PURPOSE: {{#property:p1|}} should not fail / warn; DATE:2013-11-15
|
||||
fxt.Init__docs__add(fxt.Wdoc("Q2")
|
||||
.Add_claims(fxt.Make_claim_string(1, "a"))
|
||||
.Add_sitelink("enwiki", "Test_page")
|
||||
@ -204,7 +209,7 @@ public class Wdata_pf_property__basic__tst {
|
||||
|
||||
fxt.Test_parse("{{#property:p1|}}", "a");
|
||||
}
|
||||
@Test public void Parse_pid() {
|
||||
@Test public void Parse_pid() {
|
||||
fxt.Test_parse_pid ("p123" , 123); // basic
|
||||
fxt.Test_parse_pid ("P123" , 123); // uppercase
|
||||
fxt.Test_parse_pid_null ("population"); // name test
|
||||
|
Loading…
Reference in New Issue
Block a user