[ 
https://issues.apache.org/jira/browse/LUCENE-7412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15426350#comment-15426350
 ] 

Karl Wright commented on LUCENE-7412:
-------------------------------------

I wrote a test case that demonstrates the problem.

{code}
  @Test
  public void testPolygonFailureCase1() {
    /*
GeoCompositeMembershipShape: {[
 GeoConvexPolygon: {planetmodel=PlanetModel.WGS84, points=[
  [lat=1.5707963267948966, lon=-3.141592653589793([X=-6.109531986173988E-17, 
Y=-7.482018791156346E-33, Z=0.997762292022105])], 
  [lat=1.0402618673239572, lon=-1.4892083512036773([X=0.04118030251401391, 
Y=-0.5036145102457217, Z=0.8613451288212502])], 
  [lat=-1.0850383189690824, lon=2.4457272005608357E-47([X=0.46617432552507954, 
Y=1.1401352281397884E-47, Z=-0.8829869207594466])]], internalEdges={2}}, 
 GeoConvexPolygon: {planetmodel=PlanetModel.WGS84, points=[
  [lat=-0.6370451769779303, lon=2.5318373679431616([X=-0.658944502285364, 
Y=0.4603087595301997, Z=-0.5947795941526743])], 
  [lat=1.5707963267948966, lon=-3.141592653589793([X=-6.109531986173988E-17, 
Y=-7.482018791156346E-33, Z=0.997762292022105])], 
  [lat=-1.0850383189690824, lon=2.4457272005608357E-47([X=0.46617432552507954, 
Y=1.1401352281397884E-47, Z=-0.8829869207594466])], 
  [lat=-0.5703530503197992, lon=-3.141592653589793([X=-0.8418255855200296, 
Y=-1.0309390087474507E-16, Z=-0.5400031327048586])]], internalEdges={1}}]}
    */
    final List<GeoPoint> poly1List = new ArrayList<>();
    poly1List.add(new GeoPoint(PlanetModel.WGS84, 1.5707963267948966, 
-3.141592653589793));
    poly1List.add(new GeoPoint(PlanetModel.WGS84, 1.0402618673239572, 
-1.4892083512036773));
    poly1List.add(new GeoPoint(PlanetModel.WGS84, -1.0850383189690824, 
2.4457272005608357E-47));
    final BitSet poly1Bitset = new BitSet();

    final GeoConvexPolygon poly1 = new GeoConvexPolygon(PlanetModel.WGS84, 
poly1List);
    final GeoConvexPolygon poly1Component = new 
GeoConvexPolygon(PlanetModel.WGS84, poly1List, poly1Bitset, true);
    
    final List<GeoPoint> poly2List = new ArrayList<>();
    poly2List.add(new GeoPoint(PlanetModel.WGS84, -0.6370451769779303, 
2.5318373679431616));
    poly2List.add(new GeoPoint(PlanetModel.WGS84, 1.5707963267948966, 
-3.141592653589793));
    poly2List.add(new GeoPoint(PlanetModel.WGS84, -1.0850383189690824, 
2.4457272005608357E-47));
    poly2List.add(new GeoPoint(PlanetModel.WGS84, -0.5703530503197992, 
-3.141592653589793));
    final BitSet poly2Bitset = new BitSet();
    poly2Bitset.set(1);
    
    final GeoConvexPolygon poly2 = new GeoConvexPolygon(PlanetModel.WGS84, 
poly2List);
    final GeoConvexPolygon poly2Component = new 
GeoConvexPolygon(PlanetModel.WGS84, poly2List, poly2Bitset, false);

    final GeoCompositeMembershipShape composite = new 
GeoCompositeMembershipShape();
    composite.addShape(poly1Component);
    composite.addShape(poly2Component);
    
    /*
[junit4]   1>     minx=0.9874902679462909 maxx=1.0011188543037524 
miny=-0.36099617898271563 maxy=0.5494521024819469 minz=-0.19522772391674148 
maxz=0.41372265979934325
    */
    final XYZSolid solid = XYZSolidFactory.makeXYZSolid(PlanetModel.WGS84, 
0.9874902679462909, 1.0011188543037524, -0.36099617898271563, 
0.5494521024819469, -0.19522772391674148, 0.41372265979934325);
    /*
   [junit4]   1>   doc=1177: [X=0.9943032637393302, Y=0.11529377312381162, 
Z=0.01747191431934325]; unquantized: [lat=0.017453291479645996, 
lon=0.11543880242053338([X=0.9943032638905158, Y=0.11529377303352693, 
Z=0.017471914157792666])]
    */
    
    final GeoPoint quantizedPoint = new GeoPoint(0.9943032637393302, 
0.11529377312381162, 0.01747191431934325);
    final GeoPoint unquantizedPoint = new GeoPoint(PlanetModel.WGS84, 
0.017453291479645996, 0.11543880242053338);
    
    assertTrue(solid.isWithin(quantizedPoint));
    assertTrue(!poly1.isWithin(quantizedPoint));
    assertTrue(!poly2.isWithin(quantizedPoint));
    assertTrue(!composite.isWithin(quantizedPoint));
    
    int relationship1 = solid.getRelationship(poly1);
    System.out.println("poly1 relationship: "+relationship1);   //Overlaps
    
    int relationship2 = solid.getRelationship(poly2);
    System.out.println("poly2 relationship: "+relationship2);   // Disjoint

    int relationshipComposite = solid.getRelationship(composite);
    System.out.println("composite relationship: "+relationshipComposite);       
// Contains!!

    assertTrue(relationshipComposite == GeoArea.OVERLAPS);
  }
{code}

What is happening is that the relationship between the solid and the component 
polygons is all correct, but the relationship between the overall composite and 
the solid is wrong.  Effectively this means that the internal edge between the 
two component polygons is necessary for the determination of the proper 
relationship, but that should not be the case.

In this example, all the solid's edge points wind up inside the composite 
polygon.  Either the edge points are incorrect, or there's an edge intersection 
we're not picking up.  Looking deeper.


> TestGeo3DPoint.testGeo3DRelations test failure
> ----------------------------------------------
>
>                 Key: LUCENE-7412
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7412
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/spatial3d
>            Reporter: Michael McCandless
>            Assignee: Karl Wright
>
> It reproduces:
> {noformat}
>    [junit4]   1> doc=23 should not have matched but did
>    [junit4]   1>   point=[X=0.9945964169637284, Y=0.017360743796216105, 
> Z=-0.11238509267616992]
>    [junit4]   1>   mappedPoint=[lat=-0.11250142194566046, 
> lon=0.017453291479645996([X=0.9945964169928142, Y=0.01736074400099093, 
> Z=-0.11238509283298634])]
>    [junit4]   1> doc=46 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=-2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=-2.915240855096914E-236, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=-2.9185025839666778E-236])]
>    [junit4]   1> doc=59 should not have matched but did
>    [junit4]   1>   point=[X=1.0008128994768453, Y=0.017469252883873243, 
> Z=0.01747191431934325]
>    [junit4]   1>   mappedPoint=[lat=0.017453291479645996, 
> lon=0.017453291479645996([X=1.0008128995370384, Y=0.01746925310095654, 
> Z=0.01747191415779267])]
>    [junit4]   1> doc=125 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=7.235987507597244E-97, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=7.244083521109649E-97])]
>    [junit4]   1> doc=243 should not have matched but did
>    [junit4]   1>   point=[X=0.9975952873944153, Y=0.08392021471535471, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=0.0, 
> lon=0.0839249100415336([X=0.9975952873501377, Y=0.08392021494259203, Z=0.0])]
>    [junit4]   1> doc=342 should not have matched but did
>    [junit4]   1>   point=[X=0.9941995353524516, Y=0.017353816325365812, 
> Z=0.11582176154966317]
>    [junit4]   1>   mappedPoint=[lat=0.11595722401420251, 
> lon=0.017453291479645996([X=0.9941995354390136, Y=0.017353816408113534, 
> Z=0.11582176139738691])]
>    [junit4]   1> doc=471 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=2.4457272005608357E-47, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=2.448463612203698E-47])]
>    [junit4]   1> doc=478 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=0.0, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=0.0])]
>    [junit4]   1> doc=507 should not have matched but did
>    [junit4]   1>   point=[X=1.0008128994768453, Y=0.017469252883873243, 
> Z=0.01747191431934325]
>    [junit4]   1>   mappedPoint=[lat=0.017453291479645996, 
> lon=0.017453291479645996([X=1.0008128995370384, Y=0.01746925310095654, 
> Z=0.01747191415779267])]
>    [junit4]   1> doc=604 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=2.4457272005608357E-47, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=2.448463612203698E-47])]
>    [junit4]   1> doc=650 should not have matched but did
>    [junit4]   1>   point=[X=1.0008128994768453, Y=0.017469252883873243, 
> Z=0.01747191431934325]
>    [junit4]   1>   mappedPoint=[lat=0.017453291479645996, 
> lon=0.017453291479645996([X=1.0008128995370384, Y=0.01746925310095654, 
> Z=0.01747191415779267])]
>    [junit4]   1> doc=743 should not have matched but did
>    [junit4]   1>   point=[X=1.0008128994768453, Y=0.017469252883873243, 
> Z=0.01747191431934325]
>    [junit4]   1>   mappedPoint=[lat=0.017453291479645996, 
> lon=0.017453291479645996([X=1.0008128995370384, Y=0.01746925310095654, 
> Z=0.01747191415779267])]
>    [junit4]   1> doc=807 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=-2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=-1.2794127972350177E-169, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=-1.280844273351233E-169])]
>    [junit4]   1> doc=826 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=2.4457272005608357E-47, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=2.448463612203698E-47])]
>    [junit4]   1> doc=931 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=0.0, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=0.0])]
>    [junit4]   1> doc=943 should not have matched but did
>    [junit4]   1>   point=[X=0.9976073946182008, Y=0.08377616574426938, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=1.2870639730949678E-163, 
> lon=0.08378051468561859([X=0.9976073946394605, Y=0.08377616594164751, 
> Z=1.2885040097598412E-163])]
>    [junit4]   1> doc=946 should not have matched but did
>    [junit4]   1>   point=[X=1.0008809877510743, Y=0.01747044164905953, 
> Z=-0.013032532267229002]
>    [junit4]   1>   mappedPoint=[lat=-0.013018342205382104, 
> lon=0.017453291479645996([X=1.000880987885291, Y=0.017470441587425285, 
> Z=-0.01303253226005935])]
>    [junit4]   1> doc=982 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=0.0, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=0.0])]
>    [junit4]   1> doc=998 should not have matched but did
>    [junit4]   1>   point=[X=0.9984329789869703, Y=0.032151205937634875, 
> Z=0.06563394006842149]
>    [junit4]   1>   mappedPoint=[lat=0.0656085955562445, 
> lon=0.03219054308233861([X=0.998432978803685, Y=0.03215120594571263, 
> Z=0.06563394025553593])]
>    [junit4]   1> doc=1005 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=2.4457272005608357E-47, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=2.448463612203698E-47])]
>    [junit4]   1> doc=1040 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=-2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=-5.063866803598018E-207, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=-5.069532531188606E-207])]
>    [junit4]   1> doc=1042 should not have matched but did
>    [junit4]   1>   point=[X=0.9945781929603313, Y=0.11425050487122357, 
> Z=-2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=-4.3091314014443453E-38, 
> lon=0.11437200407330356([X=0.9945781930019248, Y=0.11425050470015728, 
> Z=-4.3139526903169686E-38])]
>    [junit4]   1> doc=1061 should not have matched but did
>    [junit4]   1>   point=[X=1.000966378852226, Y=0.01747193203427544, 
> Z=2.3309121299774915E-10]
>    [junit4]   1>   mappedPoint=[lat=8.174609137513495E-34, 
> lon=0.017453291479645996([X=1.0009663787601641, Y=0.017471932090601616, 
> Z=8.183755331583957E-34])]
>    [junit4]   1> doc=1128 should not have matched but did
>    [junit4]   1>   point=[X=0.9904579202377298, Y=0.017288506498395972, 
> Z=0.14419792173153445]
>    [junit4]   1>   mappedPoint=[lat=0.14454969584158828, 
> lon=0.017453291479645996([X=0.9904579204054236, Y=0.017288506278659403, 
> Z=0.14419792178229177])]
>    [junit4]   1> doc=1177 should not have matched but did
>    [junit4]   1>   point=[X=0.9943032637393302, Y=0.11529377312381162, 
> Z=0.01747191431934325]
>    [junit4]   1>   mappedPoint=[lat=0.017453291479645996, 
> lon=0.11543880242053338([X=0.9943032638905158, Y=0.11529377303352693, 
> Z=0.017471914157792666])]
>    [junit4]   2> NOTE: reproduce with: ant test  -Dtestcase=TestGeo3DPoint 
> -Dtests.method=testGeo3DRelations -Dtests.seed=8ED27EC85D584E01 
> -Dtests.slow=true -Dtests.locale=bg -Dtests.timezone=Africa/El_Aaiun 
> -Dtests.asserts=true -Dtests.file.encoding=UTF8
>    [junit4] FAILURE 1.37s | TestGeo3DPoint.testGeo3DRelations <<<
>    [junit4]    > Throwable #1: java.lang.AssertionError: invalid hits for 
> shape=GeoCompositeMembershipShape: {[GeoConvexPolygon: 
> {planetmodel=PlanetModel.WGS84, points=[[lat=1.5707963267948966, 
> lon=-3.141592653589793([X=-6.109531986173988E-17, Y=-7.482018791156346E-33, 
> Z=0.997762292022105])], [lat=1.0402618673239572, 
> lon=-1.4892083512036773([X=0.04118030251401391, Y=-0.5036145102457217, 
> Z=0.8613451288212502])], [lat=-1.0850383189690824, 
> lon=2.4457272005608357E-47([X=0.46617432552507954, Y=1.1401352281397884E-47, 
> Z=-0.8829869207594466])]], internalEdges={2}}, GeoConvexPolygon: 
> {planetmodel=PlanetModel.WGS84, points=[[lat=-0.6370451769779303, 
> lon=2.5318373679431616([X=-0.658944502285364, Y=0.4603087595301997, 
> Z=-0.5947795941526743])], [lat=1.5707963267948966, 
> lon=-3.141592653589793([X=-6.109531986173988E-17, Y=-7.482018791156346E-33, 
> Z=0.997762292022105])], [lat=-1.0850383189690824, 
> lon=2.4457272005608357E-47([X=0.46617432552507954, Y=1.1401352281397884E-47, 
> Z=-0.8829869207594466])], [lat=-0.5703530503197992, 
> lon=-3.141592653589793([X=-0.8418255855200296, Y=-1.0309390087474507E-16, 
> Z=-0.5400031327048586])]], internalEdges={1}}]}
>    [junit4]    >      at 
> __randomizedtesting.SeedInfo.seed([8ED27EC85D584E01:3EAD035CD215E09D]:0)
>    [junit4]    >      at 
> org.apache.lucene.spatial3d.TestGeo3DPoint.testGeo3DRelations(TestGeo3DPoint.java:464)
>    [junit4]    >      at java.lang.Thread.run(Thread.java:745)
>    [junit4]   2> NOTE: test params are: codec=Lucene62, 
> sim=RandomSimilarity(queryNorm=true): {}, locale=bg, timezone=Africa/El_Aaiun
>    [junit4]   2> NOTE: Linux 4.2.0-42-generic amd64/Oracle Corporation 
> 1.8.0_92 (64-bit)/cpus=8,threads=1,free=472890352,total=504889344
>    [junit4]   2> NOTE: All tests run in this JVM: [TestGeo3DPoint]
>    [junit4] Completed [1/1 (1!)] in 1.60s, 1 test, 1 failure <<< FAILURES!
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to