Esempio n. 1
0
        public static void GetEdgeNodes(TabHandle feature, int part, out double startLongX, out double startLatY,
                                        out double endLongX, out double endLatY)
        {
            int vCount = Mitab.mitab_c_get_vertex_count(feature, part);

            startLongX = (double)Mitab.mitab_c_get_vertex_x(feature, part, 0);
            startLatY  = (double)Mitab.mitab_c_get_vertex_y(feature, part, 0);

            endLongX = (double)Mitab.mitab_c_get_vertex_x(feature, part, vCount - 1);
            endLatY  = (double)Mitab.mitab_c_get_vertex_y(feature, part, vCount - 1);
        }
Esempio n. 2
0
        public unsafe static void CheckProjectionLLWgs84(TabHandle mitabHandle)
        {
            TabHandle prj = Mitab.mitab_c_get_projinfo(mitabHandle);
            byte *    p   = (byte *)prj;

            if (p[0] != 1 && p[56] != 104)
            {
                Exception eb = new Exception("Invalid TAB projection. Table must be LL/Wgs84 (CoordSys 1,104)");
                throw eb;
            }
        }
Esempio n. 3
0
        public MitabColumns(TabHandle mitabHandle)
        {
            // Contract.Requires<ArgumentException>(mitabHandle != 0);

            for (int k = 0; k < Mitab.mitab_c_get_field_count(mitabHandle); k++)
            {
                Column c;

                c.name  = Mitab.mitab_c_get_field_name_csharp(mitabHandle, k);
                c.type  = Mitab.mitab_c_get_field_type(mitabHandle, k);
                c.index = k;

                columnlist.Add(c.name, c);
            }
        }
Esempio n. 4
0
        public static double[][] GetCoordsD(TabHandle feature, int part)
        {
            int vCount = Mitab.mitab_c_get_vertex_count(feature, part);

            double[][] result = new double[vCount][];

            for (int k = 0; k < vCount; k++)
            {
                double x = (double)Mitab.mitab_c_get_vertex_x(feature, part, k);
                double y = (double)Mitab.mitab_c_get_vertex_y(feature, part, k);

                result[k] = new double[2] {
                    x, y
                };
            }

            return(result);
        }
Esempio n. 5
0
        public static float[][] GetCoordsF(TabHandle feature, int part)
        {
            int vCount = Mitab.mitab_c_get_vertex_count(feature, part);

            float[][] result = new float[vCount][];

            for (int k = 0; k < vCount; k++)
            {
                float x = (float)Mitab.mitab_c_get_vertex_x(feature, part, k);
                float y = (float)Mitab.mitab_c_get_vertex_y(feature, part, k);

                result[k] = new float[2] {
                    x, y
                };
            }

            return(result);
        }
Esempio n. 6
0
        public static void GetCurrentCentroid(TabHandle feature, int part, out double cx, out double cy)
        {
            double x = 0, y = 0;

            cx = 0; cy = 0;

            int c = Mitab.mitab_c_get_vertex_count(feature, part);

            cx = Mitab.mitab_c_get_vertex_x(feature, part, 0);
            cy = Mitab.mitab_c_get_vertex_y(feature, part, 0);

            for (int k = 1; k < c; k++)
            {
                x = Mitab.mitab_c_get_vertex_x(feature, part, k);
                y = Mitab.mitab_c_get_vertex_y(feature, part, k);

                cx = (cx + x) / 2;
                cy = (cy + y) / 2;
            }
        }
Esempio n. 7
0
        public static int GetBiggestPart(TabHandle feature)
        {
            int partCount = Mitab.mitab_c_get_parts(feature);

            int biggestPart   = 0;
            int biggestVCount = 0;

            for (int part = 0; part < partCount; part++)
            {
                int vCount = Mitab.mitab_c_get_vertex_count(feature, part);

                if (vCount >= biggestVCount)
                {
                    biggestPart   = part;
                    biggestVCount = vCount;
                }
            }

            return(biggestPart);
        }