示例#1
0
        private static IGeometry ParseWkbMultiPolygon(byte[] blob, ref int offset, IGeometryFactory factory, ReadCoordinatesFunction readCoordinates, GaiaImport gaiaImport)
        {
            var number   = gaiaImport.GetInt32(blob, ref offset);
            var polygons = new IPolygon[number];

            for (var i = 0; i < number; i++)
            {
                if (blob[offset++] != (byte)GaiaGeoBlobMark.GAIA_MARK_ENTITY)
                {
                    throw new Exception();
                }

                var gt = gaiaImport.GetInt32(blob, ref offset);
                if (ToBaseGeometryType((GaiaGeoGeometry)gt) != GaiaGeoGeometry.GAIA_POLYGON)
                {
                    throw new Exception();
                }

                //Since Uncompressed MultiGeom can contain compressed we need to set it here also
                readCoordinates = SetReadCoordinatesFunction(gaiaImport, (GaiaGeoGeometry)gt);


                polygons[i] = ParseWkbPolygon(blob, ref offset, factory, readCoordinates, gaiaImport);
            }
            return(factory.CreateMultiPolygon(polygons));
        }
示例#2
0
        private static IMultiLineString ParseWkbMultiLineString(byte[] blob, ref int offset, IGeometryFactory factory, ReadCoordinatesFunction readCoordinates, GaiaImport gaiaImport)
        {
            int number      = gaiaImport.GetInt32(blob, ref offset);
            var lineStrings = new ILineString[number];

            for (var i = 0; i < number; i++)
            {
                if (blob[offset++] != (byte)GaiaGeoBlobMark.GAIA_MARK_ENTITY)
                {
                    throw new Exception();
                }

                var gt = gaiaImport.GetInt32(blob, ref offset);
                if (ToBaseGeometryType((GaiaGeoGeometry)gt) != GaiaGeoGeometry.GAIA_LINESTRING)
                {
                    throw new Exception();
                }

                //Since Uncompressed MultiGeom can contain compressed we need to set it here also
                readCoordinates = SetReadCoordinatesFunction(gaiaImport, (GaiaGeoGeometry)gt);

                lineStrings[i] = ParseWkbLineString(blob, ref offset, factory, factory.CreateLineString, readCoordinates, gaiaImport);
            }
            return(factory.CreateMultiLineString(lineStrings));
        }
示例#3
0
        private static IGeometryCollection ParseWkbGeometryCollection(byte[] blob, ref int offset, IGeometryFactory factory, GaiaImport gaiaImport)
        {
            var number     = gaiaImport.GetInt32(blob, ref offset);
            var geometries = new IGeometry[number];

            for (var i = 0; i < number; i++)
            {
                if (blob[offset++] != (byte)GaiaGeoBlobMark.GAIA_MARK_ENTITY)
                {
                    throw new Exception();
                }

                geometries[i] = ParseWkbGeometry((GaiaGeoGeometry)gaiaImport.GetInt32(blob, ref offset), blob, ref offset, factory, gaiaImport);
            }
            return(factory.CreateGeometryCollection(geometries));
        }
示例#4
0
        private static ILineString ParseWkbLineString(byte[] blob, ref int offset, IGeometryFactory factory, CreateLineStringFunction createLineStringFunction, ReadCoordinatesFunction readCoordinates, GaiaImport gaiaImport)
        {
            var number   = gaiaImport.GetInt32(blob, ref offset);
            var sequence = readCoordinates(blob, ref offset, number, gaiaImport, factory.CoordinateSequenceFactory,
                                           factory.PrecisionModel);

            return(createLineStringFunction(sequence));
        }
示例#5
0
        private static IPolygon ParseWkbPolygon(byte[] blob, ref int offset, IGeometryFactory factory, ReadCoordinatesFunction readCoordinates, GaiaImport gaiaImport)
        {
            var number = gaiaImport.GetInt32(blob, ref offset) - 1;
            var shell  = (ILinearRing)ParseWkbLineString(blob, ref offset, factory, factory.CreateLinearRing, readCoordinates, gaiaImport);
            var holes  = new ILinearRing[number];

            for (var i = 0; i < number; i++)
            {
                holes[i] = (ILinearRing)ParseWkbLineString(blob, ref offset, factory, factory.CreateLinearRing, readCoordinates, gaiaImport);
            }

            return(factory.CreatePolygon(shell, holes));
        }