package geojson import ( "testing" ) func TestFeature(t *testing.T) { testJSON(t, `{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-80.72487831115721,35.26545403190955], [-80.72135925292969,35.26727607954368], [-80.71517944335938,35.26769654625573], [-80.7125186920166,35.27035945142482], [-80.70857048034668,35.268257165144064], [-80.70479393005371,35.268397319259996], [-80.70324897766113,35.26503355355979], [-80.71088790893555,35.2553619492954], [-80.71681022644043,35.2553619492954], [-80.7150936126709,35.26054831539319], [-80.71869850158691,35.26026797976481], [-80.72032928466797,35.26061839914875], [-80.72264671325684,35.26033806376283], [-80.72487831115721,35.26545403190955] ] ] }, "id": "102374", "properties": { "name": "Plaza Road Park" } }`) } var complexFeature = `{ "id": 202418985, "type": "Feature", "properties": { "addr:full":"5607 McKinley Ave Los Angeles CA 90011", "addr:housenumber":"5607", "addr:postcode":"90011", "addr:street":"Mckinley Ave", "edtf:cessation":"uuuu", "edtf:inception":"uuuu", "geom:area":0.0, "geom:bbox":"-118.26089,33.99073,-118.26089,33.99073", "geom:latitude":33.99073, "geom:longitude":-118.26089, "iso:country":"US", "mz:hierarchy_label":1, "sg:address":"5607 McKinley Ave", "sg:city":"Los Angeles", "sg:classifiers":[ { "category":"Wholesale", "subcategory":"Toys & Hobbies", "type":"Manufacturing & Wholesale Goods" } ], "sg:owner":"simplegeo", "sg:phone":"+1 323 231 0540", "sg:postcode":"90011", "sg:province":"CA", "sg:tags":[ "wholesaler" ], "src:geom":"simplegeo", "wof:belongsto":[ 85633793, 85688637 ], "wof:breaches":[], "wof:concordances":{ "sg:id":"SG_0i3ZtGVxBmvnGGcg7wZrlY_33.990730_-118.260890@1294081369" }, "wof:country":"US", "wof:geomhash":"fa3426d7a9b6c92b5e2857b4daef560f", "wof:hierarchy":[ { "continent_id":-1, "country_id":85633793, "locality_id":-1, "neighbourhood_id":-1, "region_id":85688637, "venue_id":202418985 } ], "wof:id":202418985, "wof:lastmodified":1472331065, "wof:name":"Hotfix Wholesale Inc", "wof:parent_id":-1, "wof:placetype":"venue", "wof:repo":"whosonfirst-data-venue-us-ca", "wof:superseded_by":[], "wof:supersedes":[], "wof:tags":[ "wholesaler" ], "added:by:tidwall": "\n\"\\\\15\u00f8C 3\u0111" }, "bbox": [ -118.26089, 33.99073, -118.26089, 33.99073 ], "geometry": {"coordinates":[-118.26089,33.99073],"type":"Point"} }` func TestComplexFeature(t *testing.T) { testJSON(t, complexFeature) o, err := ObjectJSON(complexFeature) if err != nil { t.Fatal(err) } o = o } func TestIssue245(t *testing.T) { json := `{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [113.840391, 23.36073], [113.840837, 23.360618], [113.841198, 23.360528], [113.84295, 23.360252], [113.844386, 23.359914], [113.844674, 23.359847], [113.845843, 23.359466], [113.846787, 23.358753], [113.84679, 23.358751], [113.847128, 23.358254], [113.847571, 23.357602], [113.847573, 23.357598], [113.848175, 23.356521], [113.848177, 23.356517], [113.848187, 23.3565], [113.848189, 23.356497], [113.84847, 23.355449], [113.848471, 23.355445], [113.848475, 23.355126], [113.848486, 23.354203], [113.848373, 23.353516], [113.848122, 23.352467], [113.847432, 23.351258], [113.846102, 23.349542], [113.845853, 23.349288], [113.84494, 23.348358], [113.844435, 23.347908], [113.843638, 23.347198], [113.840895, 23.345392], [113.836433, 23.342373], [113.835963, 23.342033], [113.83469, 23.34111], [113.833801, 23.340465], [113.831238, 23.338917], [113.830698, 23.33835], [113.830644, 23.337639], [113.830642, 23.337639], [113.825764, 23.337862], [113.82575, 23.337897], [113.82575, 23.337899], [113.825749, 23.337901], [113.825748, 23.337905], [113.825747, 23.337907], [113.825746, 23.337909], [113.825746, 23.337912], [113.825745, 23.337914], [113.825744, 23.337916], [113.825743, 23.337919], [113.825742, 23.337921], [113.825741, 23.337923], [113.82574, 23.337926], [113.825739, 23.337928], [113.825738, 23.33793], [113.825738, 23.337933], [113.825737, 23.337935], [113.825736, 23.337937], [113.825735, 23.33794], [113.825734, 23.337942], [113.825733, 23.337944], [113.825732, 23.337947], [113.825731, 23.337949], [113.82573, 23.337951], [113.825729, 23.337954], [113.825728, 23.337956], [113.825727, 23.337959], [113.825726, 23.337962], [113.825725, 23.337964], [113.825725, 23.337966], [113.825724, 23.337969], [113.825723, 23.337971], [113.825722, 23.337973], [113.825721, 23.337975], [113.82572, 23.337978], [113.825719, 23.33798], [113.825718, 23.337982], [113.825717, 23.337985], [113.825717, 23.337987], [113.825716, 23.337989], [113.825715, 23.337992], [113.825715, 23.337994], [113.825714, 23.337996], [113.825713, 23.337999], [113.825712, 23.338001], [113.825711, 23.338003], [113.82571, 23.338006], [113.825709, 23.338008], [113.825708, 23.33801], [113.825707, 23.338013], [113.825706, 23.338015], [113.825705, 23.338018], [113.825705, 23.338021], [113.825704, 23.338023], [113.825703, 23.338025], [113.825702, 23.338028], [113.825701, 23.33803], [113.8257, 23.338032], [113.825699, 23.338035], [113.825698, 23.338037], [113.825697, 23.338039], [113.825696, 23.338042], [113.825696, 23.338044], [113.825695, 23.338046], [113.825694, 23.338049], [113.825693, 23.338051], [113.825692, 23.338053], [113.825691, 23.338056], [113.82569, 23.338058], [113.82569, 23.338061], [113.825689, 23.338063], [113.825689, 23.338065], [113.825688, 23.338068], [113.825687, 23.33807], [113.825686, 23.338072], [113.825685, 23.338075], [113.825684, 23.338078], [113.825683, 23.33808], [113.825682, 23.338083], [113.825682, 23.338085], [113.825681, 23.338087], [113.82568, 23.33809], [113.825679, 23.338092], [113.825678, 23.338094], [113.825677, 23.338097], [113.825676, 23.338099], [113.825675, 23.338101], [113.825675, 23.338104], [113.825674, 23.338106], [113.825673, 23.338108], [113.825672, 23.338111], [113.825671, 23.338113], [113.82567, 23.338115], [113.825669, 23.338118], [113.825669, 23.33812], [113.825668, 23.338123], [113.825668, 23.338125], [113.825667, 23.338127], [113.825666, 23.33813], [113.825665, 23.338132], [113.825664, 23.338134], [113.825664, 23.338138], [113.825663, 23.33814], [113.825662, 23.338142], [113.825661, 23.338145], [113.82566, 23.338147], [113.825659, 23.338149], [113.825659, 23.338152], [113.825658, 23.338154], [113.825657, 23.338156], [113.825656, 23.338159], [113.825655, 23.338161], [113.825654, 23.338164], [113.825654, 23.338166], [113.825653, 23.338168], [113.825652, 23.338171], [113.825651, 23.338173], [113.82565, 23.338175], [113.82565, 23.338178], [113.825649, 23.33818], [113.825648, 23.338182], [113.825647, 23.338185], [113.825646, 23.338187], [113.825646, 23.33819], [113.825646, 23.338192], [113.825645, 23.338194], [113.825644, 23.338197], [113.825643, 23.3382], [113.825642, 23.338202], [113.825642, 23.338205], [113.825641, 23.338207], [113.82564, 23.33821], [113.825639, 23.338212], [113.825639, 23.338214], [113.825638, 23.338217], [113.825637, 23.338219], [113.825636, 23.338221], [113.825635, 23.338224], [113.825635, 23.338226], [113.825634, 23.338229], [113.825633, 23.338231], [113.825632, 23.338233], [113.825632, 23.338236], [113.825631, 23.338238], [113.82563, 23.33824], [113.825629, 23.338243], [113.825628, 23.338245], [113.825629, 23.338248], [113.825628, 23.33825], [113.825627, 23.338252], [113.825626, 23.338255], [113.825626, 23.338257], [113.825625, 23.338259], [113.825624, 23.338262], [113.825623, 23.338265], [113.825623, 23.338268], [113.825622, 23.33827], [113.825621, 23.338272], [113.82562, 23.338275], [113.82562, 23.338277], [113.825619, 23.33828], [113.825618, 23.338282], [113.825618, 23.338284], [113.825617, 23.338287], [113.825616, 23.338289], [113.825615, 23.338292], [113.825532, 23.338833], [113.825532, 23.338835], [113.825532, 23.338838], [113.825532, 23.33884], [113.825532, 23.338843], [113.825532, 23.338845], [113.825531, 23.338848], [113.825532, 23.33885], [113.825532, 23.338853], [113.825532, 23.338855], [113.825532, 23.338858], [113.825532, 23.33886], [113.825532, 23.338863], [113.825531, 23.338865], [113.825531, 23.338868], [113.825531, 23.33887], [113.825531, 23.338873], [113.825531, 23.338875], [113.825531, 23.338878], [113.825532, 23.33888], [113.825532, 23.338883], [113.825531, 23.338885], [113.825531, 23.338888], [113.825531, 23.33889], [113.825531, 23.338893], [113.825531, 23.338895], [113.825531, 23.338898], [113.825531, 23.3389], [113.825531, 23.338903], [113.825531, 23.338905], [113.82553, 23.338908], [113.825531, 23.33891], [113.825531, 23.338913], [113.825531, 23.338915], [113.825531, 23.338918], [113.825531, 23.33892], [113.825531, 23.338923], [113.825531, 23.338925], [113.825531, 23.338928], [113.825531, 23.33893], [113.825531, 23.338933], [113.82553, 23.338935], [113.82553, 23.338938], [113.825531, 23.33894], [113.825531, 23.338942], [113.825531, 23.338945], [113.825531, 23.338947], [113.825531, 23.33895], [113.825531, 23.338952], [113.825531, 23.338956], [113.825531, 23.338958], [113.825531, 23.338961], [113.825531, 23.338963], [113.825531, 23.338966], [113.825532, 23.338968], [113.825532, 23.338971], [113.825532, 23.338973], [113.825531, 23.338976], [113.825531, 23.338978], [113.825531, 23.338981], [113.825531, 23.338983], [113.825531, 23.338986], [113.825531, 23.338988], [113.825531, 23.338991], [113.825531, 23.338993], [113.825531, 23.338996], [113.825532, 23.338998], [113.825532, 23.339001], [113.825532, 23.339003], [113.825532, 23.339006], [113.825532, 23.339008], [113.825532, 23.339011], [113.825532, 23.339013], [113.825532, 23.339016], [113.825532, 23.339018], [113.825532, 23.339021], [113.825532, 23.339023], [113.825533, 23.339026], [113.825533, 23.339028], [113.825533, 23.339031], [113.825533, 23.339033], [113.825533, 23.339036], [113.825533, 23.339038], [113.825533, 23.339041], [113.825533, 23.339043], [113.825533, 23.339046], [113.825533, 23.339048], [113.825533, 23.339051], [113.825533, 23.339053], [113.825534, 23.339056], [113.825534, 23.339058], [113.825534, 23.339061], [113.825534, 23.339063], [113.825534, 23.339066], [113.825534, 23.339068], [113.825534, 23.339071], [113.825534, 23.339073], [113.825534, 23.339076], [113.825534, 23.339078], [113.825534, 23.339081], [113.825535, 23.339083], [113.825535, 23.339086], [113.825535, 23.339088], [113.825535, 23.339091], [113.825535, 23.339093], [113.825535, 23.339096], [113.825535, 23.339098], [113.825535, 23.339101], [113.825535, 23.339103], [113.825535, 23.339106], [113.825535, 23.339108], [113.825536, 23.339111], [113.825536, 23.339113], [113.825536, 23.339116], [113.825536, 23.339118], [113.825536, 23.339121], [113.825536, 23.339123], [113.825536, 23.339125], [113.825536, 23.339128], [113.825536, 23.33913], [113.825536, 23.339133], [113.825536, 23.339135], [113.825537, 23.339138], [113.825537, 23.33914], [113.825538, 23.339143], [113.825538, 23.339145], [113.825538, 23.339148], [113.825538, 23.33915], [113.825538, 23.339153], [113.825538, 23.339156], [113.825538, 23.339159], [113.825538, 23.339161], [113.825538, 23.339164], [113.825539, 23.339166], [113.825539, 23.339169], [113.825539, 23.339171], [113.825539, 23.339174], [113.825539, 23.339176], [113.825539, 23.339179], [113.825539, 23.339181], [113.825539, 23.339184], [113.825539, 23.339186], [113.825539, 23.339189], [113.825539, 23.339191], [113.82554, 23.339194], [113.82554, 23.339196], [113.825541, 23.339199], [113.825541, 23.339201], [113.825541, 23.339204], [113.825541, 23.339206], [113.825541, 23.339209], [113.825541, 23.339211], [113.825541, 23.339214], [113.825541, 23.339216], [113.825542, 23.339219], [113.825542, 23.339221], [113.825542, 23.339224], [113.825542, 23.339226], [113.825542, 23.339229], [113.825542, 23.339231], [113.825542, 23.339234], [113.825542, 23.339236], [113.825542, 23.339239], [113.825542, 23.339241], [113.825543, 23.339244], [113.825544, 23.339246], [113.825544, 23.339249], [113.825544, 23.339251], [113.825544, 23.339254], [113.825544, 23.339256], [113.825544, 23.339259], [113.825544, 23.339261], [113.825544, 23.339264], [113.825544, 23.339266], [113.825544, 23.339269], [113.825544, 23.339271], [113.825545, 23.339274], [113.825545, 23.339276], [113.825545, 23.339279], [113.825545, 23.339281], [113.825545, 23.339284], [113.825675, 23.341405], [113.825676, 23.341408], [113.825676, 23.34141], [113.825676, 23.341413], [113.825676, 23.341415], [113.825676, 23.341418], [113.825676, 23.34142], [113.825676, 23.341423], [113.825676, 23.341425], [113.825676, 23.341428], [113.825676, 23.34143], [113.825676, 23.341433], [113.825676, 23.341435], [113.825677, 23.341438], [113.825677, 23.34144], [113.825677, 23.341443], [113.825678, 23.341445], [113.825678, 23.341448], [113.825678, 23.34145], [113.825678, 23.341453], [113.825678, 23.341455], [113.825678, 23.341458], [113.825678, 23.34146], [113.825679, 23.341463], [113.825679, 23.341465], [113.825679, 23.341468], [113.825679, 23.34147], [113.825679, 23.341473], [113.825679, 23.341475], [113.825679, 23.341478], [113.825679, 23.34148], [113.825679, 23.341483], [113.825679, 23.341485], [113.82568, 23.341488], [113.825681, 23.34149], [113.825681, 23.341493], [113.825681, 23.341495], [113.825681, 23.341498], [113.825681, 23.3415], [113.825681, 23.341503], [113.825681, 23.341505], [113.825681, 23.341508], [113.825681, 23.34151], [113.825681, 23.341513], [113.825681, 23.341515], [113.825682, 23.341518], [113.825682, 23.34152], [113.825682, 23.341524], [113.825682, 23.341526], [113.825682, 23.341529], [113.825682, 23.341531], [113.825682, 23.341534], [113.825683, 23.341536], [113.825683, 23.341539], [113.825683, 23.341541], [113.825684, 23.341544], [113.825684, 23.341546], [113.825684, 23.341549], [113.825684, 23.341551], [113.825684, 23.341554], [113.825684, 23.341556], [113.825684, 23.341558], [113.825684, 23.341561], [113.825684, 23.341563], [113.825684, 23.341566], [113.825684, 23.341568], [113.825684, 23.341571], [113.825685, 23.341573], [113.825685, 23.341576], [113.825685, 23.341578], [113.825685, 23.341581], [113.825685, 23.341583], [113.825686, 23.341586], [113.825686, 23.341588], [113.825686, 23.341591], [113.825686, 23.341593], [113.825686, 23.341596], [113.825687, 23.341598], [113.825687, 23.341601], [113.825687, 23.341603], [113.825687, 23.341606], [113.825687, 23.341608], [113.825687, 23.341611], [113.825687, 23.341613], [113.825687, 23.341616], [113.825687, 23.341618], [113.825687, 23.341621], [113.825687, 23.341623], [113.825688, 23.341626], [113.825688, 23.341628], [113.825688, 23.341631], [113.825688, 23.341633], [113.825688, 23.341636], [113.825688, 23.341638], [113.825688, 23.341641], [113.825688, 23.341643], [113.825688, 23.341646], [113.825688, 23.341648], [113.825689, 23.341651], [113.82569, 23.341653], [113.82569, 23.341656], [113.82569, 23.341658], [113.82569, 23.341661], [113.82569, 23.341663], [113.82569, 23.341666], [113.82569, 23.341668], [113.82569, 23.341671], [113.82569, 23.341673], [113.82569, 23.341676], [113.82569, 23.341678], [113.825691, 23.341681], [113.825691, 23.341683], [113.825691, 23.341686], [113.825691, 23.341688], [113.825691, 23.341691], [113.825691, 23.341693], [113.825691, 23.341696], [113.825691, 23.341698], [113.825691, 23.341701], [113.825691, 23.341703], [113.825691, 23.341706], [113.825691, 23.341708], [113.825692, 23.341711], [113.825692, 23.341713], [113.825692, 23.341716], [113.825692, 23.341718], [113.825692, 23.341721], [113.825692, 23.341723], [113.825692, 23.341726], [113.825692, 23.341728], [113.825692, 23.341731], [113.825692, 23.341733], [113.825693, 23.341736], [113.825693, 23.341738], [113.825693, 23.34174], [113.825693, 23.341744], [113.825693, 23.341746], [113.825693, 23.341749], [113.825693, 23.341751], [113.825693, 23.341754], [113.825693, 23.341756], [113.825693, 23.341759], [113.825693, 23.341761], [113.825693, 23.341764], [113.825694, 23.341766], [113.825694, 23.341769], [113.825694, 23.341771], [113.825694, 23.341774], [113.825694, 23.341776], [113.825694, 23.341779], [113.825694, 23.341781], [113.825694, 23.341784], [113.825694, 23.341786], [113.825694, 23.341789], [113.825694, 23.341791], [113.825695, 23.341794], [113.825695, 23.341796], [113.825695, 23.341799], [113.825695, 23.341801], [113.825695, 23.341804], [113.825695, 23.341806], [113.825695, 23.341809], [113.825695, 23.341811], [113.825695, 23.341814], [113.825695, 23.341816], [113.825695, 23.341819], [113.825696, 23.341821], [113.825696, 23.341824], [113.825696, 23.341826], [113.825696, 23.341829], [113.825696, 23.341831], [113.825696, 23.341834], [113.825696, 23.341836], [113.825696, 23.341839], [113.825696, 23.341841], [113.825696, 23.341844], [113.825696, 23.341846], [113.825697, 23.341849], [113.825697, 23.341851], [113.825697, 23.341854], [113.825696, 23.341856], [113.825639, 23.342752], [113.825909, 23.343038], [113.826124, 23.34317], [113.826246, 23.343207], [113.826544, 23.343462], [113.826663, 23.343725], [113.826921, 23.344028], [113.826946, 23.344045], [113.827411, 23.344775], [113.827452, 23.345071], [113.827433, 23.345444], [113.827373, 23.345688], [113.827847, 23.346486], [113.827867, 23.346492], [113.828217, 23.346555], [113.828812, 23.346578], [113.829478, 23.346804], [113.829926, 23.347127], [113.830393, 23.34749], [113.830756, 23.347827], [113.83112, 23.348231], [113.832415, 23.349689], [113.833006, 23.350048], [113.834533, 23.350448], [113.835235, 23.350919], [113.835526, 23.35132], [113.836805, 23.353126], [113.836931, 23.353474], [113.837019, 23.35471], [113.837041, 23.354934], [113.837129, 23.355633], [113.837135, 23.355731], [113.837148, 23.35729], [113.837124, 23.357391], [113.837093, 23.357543], [113.837116, 23.357842], [113.837231, 23.358547], [113.837488, 23.359569], [113.837398, 23.359954], [113.838019, 23.360873], [113.838056, 23.360928], [113.840391, 23.36073] ] ] }, "properties": { "center": { "lat": 0, "lon": 0 }, "smuserid": 960, "area": 2807456.367185, "refname": "10301", "name": "", "refid": 293, "districtid": 440183, "ver": "v1.20170705", "class": "–°«¯", "id": 960, "verdate": "20170705", "oriid": 1724 } } ` poly := testJSON(t, json).(Feature) g, _ := ObjectJSON(`{"type":"Point","coordinates":[113.837019, 23.35471]}`) if !g.Within(poly) { t.Fatal("!") } g, _ = ObjectJSON(`{"type":"Point","coordinates":[114.837019, 23.35471]}`) if g.Within(poly) { t.Fatal("!") } }