Forum

Author Topic: Measure Export Scalebars - converting  (Read 1948 times)

schorge

  • Newbie
  • *
  • Posts: 5
    • View Profile
Measure Export Scalebars - converting
« on: March 27, 2019, 01:29:14 PM »
Hello,

i'm new on this sector. I'd like to parse the .xml File with the Points and Scalebars and
show the scalebar Meters.

In XML looks like this:
Code: [Select]

<marker id="0" label="marker1">
        <reference x="8.55719651120748" y="50.8246424906469" z="157.402335099158" sxyz="0.005" enabled="1"/>
      </marker>
      <marker id="1" label="marker2">
        <reference x="8.55733009829694" y="50.8246961613139" z="157.326469692128" sxyz="0.005" enabled="1"/>
      </marker>

---

<scalebar id="1" label="mylenght1">
        <endpoint marker_id="0"/>
        <endpoint marker_id="1"/>
      </scalebar>



But the Lenght shows only in the Agisoft programm.

With
Code: [Select]
sqr(((x1-x2)^2)+((y1-y2)^2)+((z1-z2)^2)) => 15,5964706
Agi-Programm scalebar length is:  11,158878 m
i have the sum of the Line between the two point, but
who can i convert the 15,96... to meters?
Is there a variable in the XML to multiplicate that?

Thank you!


« Last Edit: March 27, 2019, 02:10:15 PM by schorge »
____________________________
GERMAN - Mavic 2 Zoom

Dave Martin

  • Full Member
  • ***
  • Posts: 170
    • View Profile
Re: Measure Export Scalebars - converting
« Reply #1 on: March 27, 2019, 01:50:51 PM »
Schorge,
What units are your x, y and z?
Dave

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14840
    • View Profile
Re: Measure Export Scalebars - converting
« Reply #2 on: March 27, 2019, 01:59:26 PM »
Hello schorge,

Can you please check, if you are able to get the same result for the scale bar length, if you use coordinates for the marker from the Estimated values tab?

In case the alignment or referencing is not very accurate, you'll see considerable errors on the markers' locations, which means that the estimated markers' locations are quite off the source (measured) locations.
Best regards,
Alexey Pasumansky,
Agisoft LLC

schorge

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Measure Export Scalebars - converting
« Reply #3 on: March 27, 2019, 02:21:19 PM »
@dave: this are coordinates from WGS84 i dont now the unit,
i think it's Decimal Degrees

i have calculate here: http://www.cqsrg.org/tools/GCDistance/
but there is a difference with the meausre lenght ...

@alexey :
i have on the values table a fail of  0,04 meters and a accuratcy with 0,005m
« Last Edit: March 27, 2019, 03:33:32 PM by schorge »
____________________________
GERMAN - Mavic 2 Zoom

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14840
    • View Profile
Re: Measure Export Scalebars - converting
« Reply #4 on: March 27, 2019, 03:41:02 PM »
Hello schorge,

I have calculated the distance between two points (according to the estimated markers' locations) and have the difference about 3 cm with the result displayed for the scalebar. This difference is likely related to the number of decimal digits displayed in the Reference pane for Lat/Long, if the complete values are taken, I would likely get the identical result.

By the provided link I do not see that that the calculator is anyhow considering the point altitude. Also it seems that Latitude and Longitude values are mixed on your screenshot.

Below is my result of the calculation via the external tool:
Best regards,
Alexey Pasumansky,
Agisoft LLC

schorge

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Measure Export Scalebars - converting
« Reply #5 on: March 28, 2019, 01:22:27 PM »
Thank you, i  have now create a tool to convert the xml with c#
For those who are interested in the details:

Code: [Select]
private double convertDistWGStoMeter(double lat1, double lon1, double lat2, double lon2)
        {
            double lenght = 0;

            double a = 6378137;
            double b = 6356752.3142;
            double f = 1 / 298.257223563;  // WGS-84 ellipsoid params
            double L = (lon2 - lon1) * (Math.PI / 180);

            double U1 = Math.Atan((1 - f) * Math.Tan(Math.PI * lat1/180));
            double U2 = Math.Atan((1 - f) * Math.Tan(Math.PI * lat2/180));
            double sinU1 = Math.Sin(U1);
            double cosU1 = Math.Cos(U1);
            double sinU2 = Math.Sin(U2);
            double cosU2 = Math.Cos(U2);

            double lambda = L;
            double lambdaP = 0;
            double sinSigma;
            double cosSigma;
            double cos2SigmaM;
            double sigma;

            double sinLambda;
            double cosLambda;
            double iterLimit = 100;

            double cosSqAlpha;
            do
            {
                sinLambda = Math.Sin(lambda);
                cosLambda = Math.Cos(lambda);
                sinSigma = Math.Sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda) +
                  (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
                if (sinSigma == 0) return 0;  // co-incident points
                cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
                sigma = Math.Atan2(sinSigma, cosSigma);
                double sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
                cosSqAlpha = 1 - sinAlpha * sinAlpha;
                cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
                if (Double.IsNaN(cos2SigmaM)) cos2SigmaM = 0;  // equatorial line: cosSqAlpha=0 (�6)
                var C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
                lambdaP = lambda;
                lambda = L + (1 - C) * f * sinAlpha *
                  (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
            } while (Math.Abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
            if (iterLimit == 0) return 0;  // formula failed to converge

            double aas = ((a * a) - (b * b)) / (b * b);
            double uSq = cosSqAlpha * ((a * a) - (b * b)) / (b * b); //0.8849956586239898
            double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
            double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
            double deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
              B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
            double s = b * A * (sigma - deltaSigma);

            return s;


        }
____________________________
GERMAN - Mavic 2 Zoom