ThinkGeo.com    |     Blog    |     Wiki    |     Support

At 180 degree wrong rendering

Hi @Ethan , I’m facing a strange issue with line drawing when one line crossing from Korea to US one breakage is coming with gap on both side of the line.

Hi Bibek,

We hadn’t reproduced this issue, could you please view the sample here and modify it to reproduce the problem?

9462.zip (173.3 KB)

Regards,

Etham

In this picture the line should take the shortest path when map is wrapped. For Example ,“If a flight is going from Korea to US , It’s not gonna travel the whole world . It will cross the 180 degree Meridian line.”
Now I think it’s clear what is the issue.

Hi Bibek,

That’s clearly.

Because the wrapdateline is work for base map, so if your line need cross 180 Degree Meridian, you should want to calculate that and modify the line.

Please try this function as below, it only adjust whether corss 180 Degree Meridian by the longitude, you can modify the code to add your judging logic:

lineLayer.InternalFeatures.Add(GetLine(new PointShape(127.233000, 38.317000), new PointShape(-100.377293, 39.257254)));

private Feature GetLine(PointShape p1, PointShape p2)
    {
        PointShape westPoint;
        PointShape eastPoint;

        if (p2.X > p1.X)
        {
            westPoint = p1;
            eastPoint = p2;
        }
        else
        {
            westPoint = p2;
            eastPoint = p1;
        }


        double distanceX = eastPoint.X - westPoint.X;

        if (distanceX > 180)
        {
            MultilineShape multLine = new MultilineShape();

            LineShape line1 = new LineShape();
            line1.Vertices.Add(new Vertex(westPoint.X + 360, westPoint.Y));
            line1.Vertices.Add(new Vertex(eastPoint.X, eastPoint.Y));

            LineShape line2 = new LineShape();
            line2.Vertices.Add(new Vertex(westPoint.X, westPoint.Y));
            line2.Vertices.Add(new Vertex(eastPoint.X - 360, eastPoint.Y));


            multLine.Lines.Add(line1);
            multLine.Lines.Add(line2);

            return new Feature(multLine);
        }
        else
        {
            LineShape line = new LineShape();
            line.Vertices.Add(new Vertex(westPoint));
            line.Vertices.Add(new Vertex(eastPoint));
            return new Feature(line);
        }
    }

Wish that’s helpful.

Regards,

Ethan

9462.zip (175.6 KB)

I have modified your sample please check

Hi Bibek,

We have reviewed your code and found you didn’t set WrappingMode and WrappingExetent for layer.
We modified the sample and it works fine. Please check it.
9462_20190220.zip (176.2 KB)

If you have an questions, please feel free to contact us.

Thanks,
Rex

Ok thanks . I need that layer overlay tile type to single mode.
Can you Check that ?
Also , In your sample that line is not rendering on zoom in and zoom out.

Hi Bibek,

Here is the modified sample which use the SingleTile and solve the line looks strange when zoom in and zoom out.

Please view it.

9462_Projection.zip (173.7 KB)

Wish that’s helpful.

Regards,

Ethan