public static void SetWorldPosition(this SuperLayer layer, SuperMap map, SuperImportContext context)
        {
            // Accumlate positions up the tree
            Vector3 position_w = new Vector3();

            foreach (var parent in layer.gameObject.GetComponentsInParent <SuperLayer>())
            {
                position_w   += (Vector3)context.MakePoint(parent.m_OffsetX, parent.m_OffsetY);
                position_w.z += parent.gameObject.GetSuperPropertyValueFloat(StringConstants.Unity_ZPosition, 0);
            }

            // Add an additional offset if our tileset is present. These coordinates have already been transformed.
            if (layer is SuperTileLayer || layer.GetComponent <Tilemap>() != null || layer.GetComponent <SuperTilesAsObjectsTilemap>() != null)
            {
                position_w += context.TilemapOffset;
            }

            layer.transform.position = position_w;

            // This sucks but we have to correct for isometric orientation for image layers
            if (layer is SuperImageLayer && map.m_Orientation == MapOrientation.Isometric)
            {
                float dx = context.MakeScalar(map.m_Height * map.m_TileHeight);
                layer.transform.Translate(-dx, 0, 0);
            }
        }
Exemplo n.º 2
0
        public void PlaceTileColliders(SuperMap map, SuperTile tile, TileIdMath tileId, Vector3Int pos)
        {
            Assert.IsNotNull(m_Tilemap, "Need a Tilemap component if we are going to gather tile colliders");

            // Tile y position is always off by one
            pos.y++;

            // Do we have any collider objects defined for this tile?
            if (!tile.m_CollisionObjects.IsEmpty())
            {
                var polygons = AcquireTilePolygonCollection(tile, tileId);

                float cell_w     = m_Tilemap.cellSize.x;
                float cell_h     = m_Tilemap.cellSize.y;
                float halfCell_w = m_Tilemap.cellSize.x * 0.5f;
                float halfCell_h = m_Tilemap.cellSize.y * 0.5f;

                foreach (var poly in polygons.Polygons)
                {
                    // Offset the polygon so that it is in the location of the tile
                    var tileHeight = m_ImportContext.MakeScalar(tile.m_Height);
                    var tileDiff   = m_Tilemap.cellSize.y - tileHeight;

                    var offset = Vector2.zero;

                    // Our offset depends on map orientation. Isometric is such a pain in the ass.
                    if (map.m_Orientation == MapOrientation.Isometric)
                    {
                        var x = (pos.x - pos.y) * halfCell_w;
                        var y = (pos.x + pos.y) * halfCell_h;
                        offset = new Vector2(x + halfCell_w, y - tileDiff);
                    }
                    else
                    {
                        offset = new Vector2(pos.x * cell_w, pos.y * cell_h - tileDiff);
                    }

                    var points = poly.Points.Select(pt => pt + offset).ToArray();

                    CollisionClipperKey key = poly.MakeKey();
                    CollisionClipper    clipper;
                    if (!m_CollisionClippers.TryGetValue(key, out clipper))
                    {
                        // Add a new clipper for the layer
                        clipper = new CollisionClipper();
                        m_CollisionClippers.Add(key, clipper);
                    }

                    // Add the path to our clipper
                    if (poly.IsClosed)
                    {
                        clipper.AddClosedPath(points);
                    }
                    else
                    {
                        clipper.AddOpenPath(points);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void PlaceTileColliders(SuperMap map, SuperTile tile, TileIdMath tileId, Vector3Int pos)
        {
            // Do we have any collider objects defined for this tile?
            if (!tile.m_CollisionObjects.IsEmpty())
            {
                var polygons = AcquireTilePolygonCollection(tile, tileId, map.m_Orientation);

                foreach (var poly in polygons.Polygons)
                {
                    // Offset the polygon so that it is in the location of the tile
                    var offset = map.CellPositionToLocalPosition(pos.x, pos.y, m_ImportContext);

                    var points = poly.Points.Select(pt => pt + offset).ToArray();

                    CollisionClipperKey key = poly.MakeKey();
                    CollisionClipper    clipper;
                    if (!m_CollisionClippers.TryGetValue(key, out clipper))
                    {
                        // Add a new clipper for the layer
                        clipper = new CollisionClipper();
                        m_CollisionClippers.Add(key, clipper);
                    }

                    // Add the path to our clipper
                    if (poly.IsClosed)
                    {
                        clipper.AddClosedPath(points);
                    }
                    else
                    {
                        clipper.AddOpenPath(points);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static Vector2 CellPositionToLocalPosition(this SuperMap superMap, int cx, int cy, SuperImportContext context)
        {
            var grid  = superMap.GetComponentInChildren <Grid>();
            var local = grid.CellToLocal(new Vector3Int(cx, cy, 0));

            return(local);
        }
Exemplo n.º 5
0
        public static void UpdateProperties(this SuperMap superMap, SuperImportContext importContext)
        {
            var cellSize = superMap.CalculateCellSize();

            // The cell size has to take pixels per unit into account
            superMap.CellSize = importContext.MakeSize(cellSize);
        }
 private void Measure(SuperMap.Web.Core.Geometry geo)
 {
     MeasureParameters parameters = new MeasureParameters { Geometry = geo, Unit = Unit.Kilometer };
     MeasureService measureService = new MeasureService(url);
     measureService.ProcessAsync(parameters);
     measureService.ProcessCompleted += new EventHandler<MeasureEventArgs>(measureService_ProcessCompleted);
     measureService.Failed += new EventHandler<ServiceFailedEventArgs>(measureService_Failed);
 }
        public static Vector2 GetTileAnchor(this SuperMap superMap)
        {
            if (superMap.m_Orientation == MapOrientation.Isometric)
            {
                return(new Vector2(-0.5f, -0.5f));
            }

            return(Vector2.zero);
        }
Exemplo n.º 8
0
        // The map object is our Main Asset - the prefab that is created in our scene when dragged into the hierarchy
        private bool PrepareMainObject()
        {
            var icon = SuperIcons.GetTmxIcon();

            var goGrid = new GameObject("_MapMainObject");

            SuperImportContext.AddObjectToAsset("_MapPrfab", goGrid, icon);
            SuperImportContext.SetMainObject(goGrid);
            m_MapComponent = goGrid.AddComponent <SuperMap>();

            return(true);
        }
        public static void UpdateProperties(this SuperMap superMap, SuperImportContext importContext)
        {
            var cellSize = superMap.CalculateCellSize();

            // The cell size has to take pixels per unit into account for x and y
            // z is always 1 so we can use Transparency Sort Axis
            float x = importContext.MakeScalar(cellSize.x);
            float y = importContext.MakeScalar(cellSize.y);
            float z = 1.0f;

            superMap.CellSize = new Vector3(x, y, z);
        }
 //对目标地物进行查询
 private void queryFeature(SuperMap.Web.Core.Geometry geo)
 {
     GetFeaturesByGeometryParameters param = new GetFeaturesByGeometryParameters
     {
         DatasetNames = new string[] { "Jingjin:Landuse_R" },
         SpatialQueryMode = SpatialQueryMode.INTERSECT,
         Geometry = geo,
     };
     GetFeaturesByGeometryService query = new GetFeaturesByGeometryService(url1);
     query.ProcessAsync(param);
     query.ProcessCompleted += new EventHandler<GetFeaturesEventArgs>(query_ProcessCompleted);
     query.Failed += new EventHandler<ServiceFailedEventArgs>(query_Failed);
 }
        // The map object is our Main Asset - the prefab that is created in our scene when dragged into the hierarchy
        private bool PrepareMainObject()
        {
            var icon = SuperImportContext.Icons.TmxIcon;

            // The Main Gameobject is our grid containing all the layers
            var goGrid = new GameObject("_MapMainObject");

            SuperImportContext.AddObjectToAsset("_MapPrfab", goGrid, icon);
            SuperImportContext.SetMainObject(goGrid);
            m_MapComponent = goGrid.AddComponent <SuperMap>();

            return(true);
        }
Exemplo n.º 12
0
    public void SetBound(GameObject map)
    {
        //atributos del mapa tiled pasado como parametro map
        //Tiled2Unity.TiledMap config = map.GetComponent<Tiled2Unity.TiledMap>();
        //cantidad de celdas que tiene la camara, por lo general 5
        SuperMap config     = map.GetComponent <SuperMap>();
        float    cameraSize = Camera.main.orthographicSize;

        tLX = map.transform.position.x + cameraSize;
        tLY = map.transform.position.y - cameraSize;
        //bRX = map.transform.position.x + config.NumTilesWide - cameraSize;
        bRX = map.transform.position.x + config.m_Width - cameraSize;
        bRY = map.transform.position.y - config.m_Height + cameraSize;

        //FastMove();
    }
        public static Vector2 MapCoordinatesToPositionPPU(this SuperMap superMap, int cx, int cy)
        {
            float w = superMap.CellSize.x;
            float h = superMap.CellSize.y;

            if (superMap.m_Orientation == MapOrientation.Isometric)
            {
                var x = (cx - cy) * w * 0.5f;
                var y = (cx + cy) * h * 0.5f;
                return(new Vector2(x, -y));
            }
            else
            {
                return(new Vector2(cx * w, -cy * h));
            }
        }
Exemplo n.º 14
0
        public void PlaceTileColliders(SuperMap map, SuperTile tile, TileIdMath tileId, Vector3Int pos)
        {
            Assert.IsNotNull(m_Tilemap, "Need a Tilemap component if we are going to gather tile colliders");

            // Do we have any collider objects defined for this tile?
            if (!tile.m_CollisionObjects.IsEmpty())
            {
                var polygons = AcquireTilePolygonCollection(tile, tileId, map.m_Orientation);

                foreach (var poly in polygons.Polygons)
                {
                    // Offset the polygon so that it is in the location of the tile
                    var offset = map.CellPositionToLocalPosition(pos.x, pos.y);

                    if (map.m_Orientation == MapOrientation.Isometric || map.m_Orientation == MapOrientation.Staggered)
                    {
                        offset -= m_ImportContext.MakePointPPU(map.m_TileWidth, 0) * 0.5f;
                    }
                    else if (map.m_Orientation == MapOrientation.Hexagonal)
                    {
                        offset -= m_ImportContext.MakePointPPU(map.m_TileWidth, map.m_TileHeight) * 0.5f;
                    }

                    var points = poly.Points.Select(pt => pt + offset).ToArray();

                    CollisionClipperKey key = poly.MakeKey();
                    CollisionClipper    clipper;
                    if (!m_CollisionClippers.TryGetValue(key, out clipper))
                    {
                        // Add a new clipper for the layer
                        clipper = new CollisionClipper();
                        m_CollisionClippers.Add(key, clipper);
                    }

                    // Add the path to our clipper
                    if (poly.IsClosed)
                    {
                        clipper.AddClosedPath(points);
                    }
                    else
                    {
                        clipper.AddOpenPath(points);
                    }
                }
            }
        }
        private static GameObject CreateNavMeshObject(SuperMap map)
        {
            var go = GameObject.CreatePrimitive(PrimitiveType.Plane);

            go.name = "NavMesh";
            go.transform.rotation = Quaternion.Euler(270, 0, 0);
            go.AddComponent <NavMeshSurface>();
            var surfaceBaker = go.AddComponent <Surface2DBaker>();

            surfaceBaker.ObjectsContainingObstacles.Add(map.gameObject);

            go.GetComponent <MeshRenderer>().enabled = false;
            go.GetComponent <MeshCollider>().enabled = false;

            SetNavMeshPlaneScaleAndPosition(go, map);

            return(go);
        }
        //根据地图缩放,实现点的聚类功能
        private void Map_ViewBoundsChanged(object sender, SuperMap.Web.Mapping.ViewBoundsEventArgs e)
        {
            if (e.OldViewBounds.IsEmpty)
            {
                featuresLayer = this.MyMap.Layers["MyFeaturesLayer"] as FeaturesLayer;
                featuresLayer.Clusterer = myFlareClusterer;

                //随机生成点
                for (int i = 0; i < 500; i++)
                {
                    double x = random.NextDouble() * (ChinaRight - ChinaLeft) + ChinaLeft;
                    double y = random.NextDouble() * (ChinaTop - ChinaBottom) + ChinaBottom;
                    Feature feature = new Feature();
                    feature.Geometry = new GeoPoint(x, y);
                    feature.Style = MediumMarkerStyle;
                    feature.ToolTip = new TextBlock() { Text = i.ToString() };
                    featuresLayer.Features.Add(feature);
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>${utility_XMLHelper_method_FromGeometry_D}</summary>
        public static XElement FromGeometry(SuperMap.Web.Core.Geometry geo)
        {
            if (geo == null)
            {
                return null;
            }

            XElement xe = null;
            if (geo is GeoPoint)
            {
                xe = new XElement("{" + gml + "}Point");
                XElement coordinates = new XElement("{" + gml + "}coordinates", XMLHelper.GetCoorStr((geo as GeoPoint).Location));
                xe.Add(coordinates);
            }
            else if (geo is GeoLine)
            {
                //xe = new XElement(XName.Get("MultiLineString", gml), new XAttribute("{" + defaultNS + "}gml", gml));
                xe = new XElement("{" + gml + "}MultiLineString");
                foreach (Point2DCollection item in (geo as GeoLine).Parts)
                {
                    XElement coordinates = new XElement("{" + gml + "}coordinates", XMLHelper.GetCoorStr(item));
                    XElement LineString = new XElement("{" + gml + "}LineString", coordinates);
                    xe.Add(new XElement("{" + gml + "}lineStringMember", LineString));
                }
            }
            else if (geo is GeoRegion)
            {
                xe = new XElement("{" + gml + "}MultiPolygon");
                foreach (Point2DCollection item in (geo as GeoRegion).Parts)
                {
                    XElement coordinates = new XElement("{" + gml + "}coordinates", XMLHelper.GetCoorStr(item));
                    XElement linearRing = new XElement("{" + gml + "}LinearRing", coordinates);
                    XElement outerBoundaryIs = new XElement("{" + gml + "}outerBoundaryIs", linearRing);
                    XElement polygon = new XElement("{" + gml + "}Polygon", outerBoundaryIs);
                    xe.Add(new XElement("{" + gml + "}polygonMember", polygon));
                }
            }
            else
            { }
            return xe;
        }
        //根据地图缩放,实现点的聚类功能
        private void Map_ViewBoundsChanged(object sender, SuperMap.Web.Mapping.ViewBoundsEventArgs e)
        {
            if (e.OldViewBounds.IsEmpty)
            {
                featuresLayer = this.MyMap.Layers["MyFeaturesLayer"] as FeaturesLayer;
                featuresLayer1 = this.MyMap.Layers["MyFeaturesLayer1"] as FeaturesLayer;
                featuresLayer.Clusterer = myScatterClusterer;

                //随机生成点
                for (int i = 0; i < 500; i++)
                {
                    double x = random.NextDouble() * (ChinaRight - ChinaLeft) + ChinaLeft;
                    double y = random.NextDouble() * (ChinaTop - ChinaBottom) + ChinaBottom;
                    Feature feature = new Feature();
                    feature.Geometry = new GeoPoint(x, y);
                    feature.Style = MediumMarkerStyle;
                    feature.ToolTip = new TextBlock() { Text = i.ToString(System.Globalization.CultureInfo.InvariantCulture) };
                    featuresLayer.Features.Add(feature);
                }
                featuresLayer.Clusterer = myScatterClusterer;

                region = new Feature
                {
                    Geometry = new GeoRegion
                    {
                        Parts = new ObservableCollection<Point2DCollection>
                           {
                               new Point2DCollection
                               {
                                   new Point2D{ X=100,Y=20},
                                   new Point2D{ X=120,Y=20},
                                   new Point2D{ X=120,Y=30},
                                   new Point2D{ X=100,Y=30},
                                   new Point2D{ X=100,Y=20},
                               }
                           }
                    }
                };
            }
        }
Exemplo n.º 19
0
 private PathGeometry BuildGeoLine(SuperMap.WinRT.Core.GeoLine geoLine)
 {
     PathGeometry geometry = new PathGeometry();
     Rectangle2D bounds = geoLine.Bounds;
     if (!Rectangle2D.IsNullOrEmpty(bounds))
     {
         Point topLeft = this.MapPointToScreen(new Point2D(bounds.Left, bounds.Top));
         foreach (Point2DCollection points in geoLine.Parts)
         {
             if (points.Count >= 2)
             {
                 PathFigure figure = new PathFigure();
                 Point point = this.MapPointToScreen(points[0]);
                 point.X -= topLeft.X;
                 point.Y -= topLeft.Y;
                 figure.StartPoint = point;
                 for (int i = 1; i < points.Count; i++)
                 {
                     point = this.MapPointToScreen(points[i]);
                     point.X -= topLeft.X;
                     point.Y -= topLeft.Y;
                     figure.Segments.Add(new LineSegment { Point = point });
                 }
                 geometry.Figures.Add(figure);
             }
         }
     }
     geometry.Transform = new ScaleTransform();
     return geometry;
 }
 private PathGeometry BuildGeoRegion(SuperMap.Web.Core.GeoRegion geoRegion)
 {
     PathGeometry geometry = new System.Windows.Media.PathGeometry();
     PathFigure figure = null;
     Rectangle2D bounds = geoRegion.Bounds;
     if (!bounds.IsEmpty)
     {
         Point topLeft = this.MapPointToScreen(new Point2D(bounds.Left, bounds.Top));
         foreach (Point2DCollection points in geoRegion.Parts)
         {
             if (points.Count >= 3)
             {
                 figure = new PathFigure();
                 //是否要再加一次第一个点。
                 //figure.IsClosed = true;
                 Point point = this.MapPointToScreen(points[0]);
                 point.X -= topLeft.X;
                 point.Y -= topLeft.Y;
                 figure.StartPoint = point;
                 for (int i = 1; i < points.Count; i++)
                 {
                     point = this.MapPointToScreen(points[i]);
                     point.X -= topLeft.X;
                     point.Y -= topLeft.Y;
                     figure.Segments.Add(new LineSegment { Point = point });
                 }
                 geometry.Figures.Add(figure);
             }
         }
     }
     geometry.Transform = new ScaleTransform();
     return geometry;
 }
Exemplo n.º 21
0
        public static Vector2 CellPositionToLocalPosition(this SuperMap superMap, int cx, int cy)
        {
            var grid = superMap.GetComponentInChildren <Grid>();

            return(grid.CellToLocal(new Vector3Int(cx, cy, 0)));
        }
        private static void SetNavMeshPlaneScaleAndPosition(GameObject navMeshGameObject, SuperMap map)
        {
            var grid   = map.GetComponent <Grid>();
            var scaleX = map.m_Width * grid.cellSize.x / 10;
            var scaleZ = map.m_Height * grid.cellSize.y / 10;
            var posX   = map.m_Width * grid.cellSize.x / 2;
            var posY   = -(map.m_Height * grid.cellSize.y / 2);

            navMeshGameObject.transform.position   = new Vector3(posX, posY, 0);
            navMeshGameObject.transform.localScale = new Vector3(scaleX, 0, scaleZ);
        }
 void MyMap_ViewBoundsChanged(object sender, SuperMap.WinRT.Mapping.ViewBoundsEventArgs e)
 {
     this.scale.Text = "Scale:" + MyMap.Scale.ToString();
     this.center.Text = "Center:" + MyMap.Center.ToString();
     this.viewbounds.Text = "ViewBounds:" + MyMap.ViewBounds.ToString();
 }
        //编辑地物形状
        private void editEntity_GeometryEdit(object sender, SuperMap.Web.Actions.Edit.GeometryEditEventArgs e)
        {
            if (e.Action == SuperMap.Web.Actions.Edit.GeometryEditAction.EditCompleted)
            {
                Point2DCollection ps = new Point2DCollection();

                //记录编辑后的地物结点
                GeoRegion region = e.Feature.Geometry as GeoRegion;
                for (int i = 0; i < region.Parts.Count; i++)
                {
                    for (int j = 0; j < region.Parts[i].Count; j++)
                    {
                        ps.Add(new Point2D(region.Parts[i][j].X, region.Parts[i][j].Y));
                    }
                }

                shape = new ServerGeometry
                {
                    Feature = ServerFeatureType.Polygon,
                    Point2Ds = ps
                };
                Entity entity = new Entity
                {
                    Shape = shape,
                    ID = entityID
                };
                UpdateEntityParameters parameters = new UpdateEntityParameters
                {
                    MapName = "Changchun",
                    LayerName = "Vegetable@changchun",
                    Entity = entity
                };

                //与服务器交互更新地物形状
                UpdateEntityService updateEntityService = new UpdateEntityService("http://localhost:7080/demo");
                updateEntityService.ProcessAsync(parameters);
                updateEntityService.Failed += new EventHandler<ServiceFailedEventArgs>(Service_Failed);
                updateEntityService.ProcessCompleted += new EventHandler<EditEventArgs>(Service_ProcessCompleted);
            }
        }
Exemplo n.º 25
0
 void MyMap_ResolutionsChanged(object sender, SuperMap.WinRT.Mapping.ResolutionsEventArgs e)
 {
     this.resolution_changed.Text = "resolution_changed: " + MyMap.Resolution.ToString();
 }
Exemplo n.º 26
0
 void MyMap_ViewBoundsChanged(object sender, SuperMap.WinRT.Mapping.ViewBoundsEventArgs e)
 {
     this.resolution.Text = "resolution:  " + MyMap.Resolution.ToString();
 }
 //获取服务器地图图层失败提示错误信息
 private void mapStatusService_Failed(object sender, SuperMap.Web.Service.ServiceFailedEventArgs e)
 {
     MessageBox.Show(e.Error.Message);
 }
        internal void SetClip(SuperMap.Web.Core.Geometry clippedGeometry, Rectangle2D clipbox)
        {
            this.ClippedGeometry = clippedGeometry;
            this.ClipBox = clipbox;
            this.InvalidatePath(this.Resolution, this.OriginX, this.OriginY);

            if (this.Feature.dOldInflate > 0.0)
                return;
            //当线宽的外接矩形超过范围时,线不需偏移,重置偏移值为0
            this.Feature.dOldInflate = this.Feature.dInflate;
            this.Feature.dInflate = 0;
        }
Exemplo n.º 29
0
 void mapControl1_GeometrySelectChanged(object sender, SuperMap.UI.GeometrySelectChangedEventArgs e)
 {
 }
 private void getInfoServer_Failed(object sender , SuperMap.Web.Service.ServiceFailedEventArgs e)
 {
     MessageBox.Show("获取图层状态失败。");
 }
 private void setLayersStatus_Failed(object sender , SuperMap.Web.Service.ServiceFailedEventArgs e)
 {
     MessageBox.Show("设置图层状态失败。");
 }
Exemplo n.º 32
0
 // Start is called before the first frame update
 void Start()
 {
     SuperMap superMap = SuperTestRoom.GetComponent <SuperMap>();
 }
Exemplo n.º 33
0
 void MyMap_ViewBoundsChanged(object sender, SuperMap.WinRT.Mapping.ViewBoundsEventArgs e)
 {
     this.viewBounds.Text = "viewBounds: " + MyMap.ViewBounds.ToString();
 }
        private async void Measure(SuperMap.WinRT.Core.Geometry geo)
        {
            MeasureParameters parameters = new MeasureParameters { Geometry = geo, Unit = Unit.Kilometer };

            try
            {
                MeasureService measureService = new MeasureService(url);
                var result = await measureService.ProcessAsync(parameters);
                if (result.Distance == -1)
                {
                    await MessageBox.Show(result.Area.ToString() + "平方千米");
                }
                else if (result.Area == -1)
                {
                    await MessageBox.Show(result.Distance.ToString() + "千米");
                }
                else
                {
                    await MessageBox.Show("量算没有结果!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 async void TiledDynamicRESTLayerTest_Failed(object sender, SuperMap.WinRT.Mapping.LayerFailedEventArgs e)
 {
     await MessageBox.Show(e.Error.Message);
 }
Exemplo n.º 36
0
 void MyMap_ScalesChanged(object sender, SuperMap.WinRT.Mapping.ScalesEventArgs e)
 {
     this.scale_changed.Text = "scalechanged: " + MyMap.Scale.ToString();
 }
 private void service_Failed(object sender , SuperMap.Web.Service.ServiceFailedEventArgs e)
 {
     MessageBox.Show("没有查询到结果!");
 }
Exemplo n.º 38
0
 internal void SetClip(SuperMap.WinRT.Core.Geometry clippedGeometry, Rectangle2D clipbox)
 {
     this.ClippedGeometry = clippedGeometry;
     this.ClipBox = clipbox;
     this.InvalidatePath(this.Resolution, this.OriginX, this.OriginY);
 }
 private void ser_Failed(object sender , SuperMap.Web.Service.ServiceFailedEventArgs e)
 {
 }
 void Map_PropertyChanged(object sender, SuperMap.Connector.Control.WPF.MapPropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Center")
     {
         NowCenterX.Text = Map.Center.X.ToString();
         NowCenterY.Text = Map.Center.Y.ToString();
     }
     else if (e.PropertyName == "MapLayer")
     {
         this.BoundsLeft.Text = Map.Bounds.LeftBottom.X.ToString();
         this.BoundsTop.Text = Map.Bounds.RightTop.Y.ToString();
         this.BoundsRight.Text = Map.Bounds.RightTop.X.ToString();
         this.BoundsBottom.Text = Map.Bounds.LeftBottom.Y.ToString();
     }
     else if (e.PropertyName == "ViewBounds")
     {
         _sync.Post(new SendOrPostCallback(UpdateViewBounds),null);
     }
 }
        public static Vector2 CellPositionToLocalPosition(this SuperMap superMap, int cx, int cy, SuperImportContext context)
        {
            var grid  = superMap.GetComponentInChildren <Grid>();
            var local = grid.CellToLocal(new Vector3Int(cx, cy, 0));

            if (superMap.m_Orientation == MapOrientation.Orthogonal)
            {
                local.y -= grid.cellSize.y;
            }
            else if (superMap.m_Orientation == MapOrientation.Isometric)
            {
                local.x -= grid.cellSize.x * 0.5f;
                local.y -= grid.cellSize.y;
            }
            else if (superMap.m_Orientation == MapOrientation.Staggered)
            {
                if (superMap.m_StaggerAxis == StaggerAxis.Y)
                {
                    local.y -= grid.cellSize.y;

                    if (superMap.m_StaggerIndex == StaggerIndex.Even)
                    {
                        local.x += grid.cellSize.x * 0.5f;
                    }
                }
                else
                {
                    if (superMap.m_StaggerIndex == StaggerIndex.Odd)
                    {
                        local.y -= grid.cellSize.y;
                    }
                    else
                    {
                        local.y -= grid.cellSize.y * 1.5f;
                    }
                }
            }
            else if (superMap.m_Orientation == MapOrientation.Hexagonal)
            {
                if (superMap.m_StaggerAxis == StaggerAxis.X && superMap.m_StaggerIndex == StaggerIndex.Odd)
                {
                    local.x -= grid.cellSize.y * 0.75f;
                    local.y -= grid.cellSize.x * 1.5f;
                }
                else if (superMap.m_StaggerAxis == StaggerAxis.X && superMap.m_StaggerIndex == StaggerIndex.Even)
                {
                    local.y -= grid.cellSize.x * 1.5f;
                }
                else if (superMap.m_StaggerAxis == StaggerAxis.Y && superMap.m_StaggerIndex == StaggerIndex.Odd)
                {
                    local.y -= grid.cellSize.y;
                }
                else
                {
                    // Y-Even
                    local.y -= grid.cellSize.y * 0.25f;
                }
            }

            return(local);
        }
        private PathGeometry BuildGeoLine(SuperMap.Web.Core.GeoLine geoLine)
        {
            PathGeometry geometry = new PathGeometry();
            Rectangle2D bounds = geoLine.Bounds;
            if (!bounds.IsEmpty)
            {
                Double dInflate = 0;
                //扩展外接矩形
                if (this.Feature != null && this.Feature.Style != null && this.Feature.Style is LineStyle)
                {

                    LineStyle lineStyle = this.Feature.Style as LineStyle;
                    if (!double.IsNaN(lineStyle.StrokeThickness))
                    {
                        dInflate = this.Feature.dInflate;
                    }
                }
                Point topLeft = this.MapPointToScreen(new Point2D(bounds.Left - dInflate, bounds.Top + dInflate));
                foreach (Point2DCollection points in geoLine.Parts)
                {
                    if (points.Count >= 2)
                    {
                        PathFigure figure = new PathFigure();
                        Point point = this.MapPointToScreen(points[0]);
                        point.X -= topLeft.X;
                        point.Y -= topLeft.Y;
                        figure.StartPoint = point;
                        for (int i = 1; i < points.Count; i++)
                        {
                            point = this.MapPointToScreen(points[i]);
                            point.X -= topLeft.X;
                            point.Y -= topLeft.Y;
                            figure.Segments.Add(new LineSegment { Point = point });
                        }
                        geometry.Figures.Add(figure);
                    }
                }
            }
            geometry.Transform = new ScaleTransform();
            return geometry;
        }
Exemplo n.º 43
0
 internal void SetBoundedStyle(SuperMap.WinRT.Core.Style style)
 {
     if (this.dataContext.Style != style)
     {
         this.dataContext.Style = style;
         this.RaisePropertyChanged("Style");
         this.SetElementReference(null);
     }
 }
Exemplo n.º 44
0
        public string mo;//定义全局变量:模板路径
       
        /// <summary>
        /// 初始化
        /// </summary>
        public ImportTool(SuperMap.Data.Workspace workspace)
        {
            m_workspace = workspace;
            m_dataImport = new DataImport();

        }
 //中心点查询功能查询地物
 private void queryEntity(SuperMap.Web.Core.Geometry entity)
 {
     QueryByCenterParameters parameters = new QueryByCenterParameters
     {
         CenterPoint = entity.Bounds.Center,
         Tolerance = 5,
         MapName = "Changchun",
         IsNearest = true,
         QueryParam = new QueryParam { QueryLayerParams = new List<QueryLayerParam>() { qureyLayerParam } }
     };
     QueryByCenterService query = new QueryByCenterService("http://localhost:7080/demo");
     query.ProcessAsync(parameters);
     query.Failed += (s, args) => { MessageBox.Show(args.Error.ToString()); };
     query.ProcessCompleted += new EventHandler<QueryEventArgs>(query_ProcessCompleted);
 }
Exemplo n.º 46
0
        private Theme getTheme(SuperMap.Data.Workspace wks, string mapName)
        {
            try
            {
                SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(wks);
                map.Open(mapName);
                Layers layers = map.Layers;
                Layer layer = null;
                for (Int32 i = 0; i < layers.Count; i++)
                {
                    layer = layers[i];
                    if (layer.Theme != null)
                    {
                        break;
                    }
                }
                Theme theme = layer.Theme;
                return theme;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
 async void OverViewMap_Failed(object sender, SuperMap.WinRT.Mapping.LayerFailedEventArgs e)
 {
     await MessageBox.Show(e.Error.Message);
 }
        private static void SetNavMeshPlaneScaleAndPosition(GameObject navMeshGameObject, SuperMap map)
        {
            var scaleX = map.m_Width * map.m_TileWidth / 10;
            var scaleZ = map.m_Height * map.m_TileHeight / 10;
            var posX   = map.m_Width * map.m_TileWidth / 2;
            var posY   = -(map.m_Height * map.m_TileHeight / 2);

            navMeshGameObject.transform.position   = new Vector3(posX, posY, 0);
            navMeshGameObject.transform.localScale = new Vector3(scaleX, 0, scaleZ);
        }