$geoNear

怎么使用mongoose的geoNear  

2014-11-26 15:05:20|  分类: mongodb |  标签:mongoose  |举报|字号 订阅

下载LOFTER我的照片书  |

起因

在开发的时候碰到一个情况,数据源有100个景点,需要对给出的一个点,求距离它最近的景点,并且在前端下拉翻页的过程中,依距离顺序依次显示出来。大众点评做出了这个效果,但是以我现阶段的经验,想不出比较完美的解决方案。尤其是处理下拉翻页还能保证排序的效果,这一点是需要先对所有的点求距离,然后将所有点进行排序然后输出吗?这样效率不低吗?后来想到,mongodb有一个查询操作是geoNear,于是思考通过这种方案来解决排序效率的问题。

过程

在网上查了一下,大概需要三步:

  1. 确保有loc:[longitude, latitude]属性
  2. loc增加索引AttractionSchema.index({loc: '2d'});
  3. 使用geoNear

    Model.geoNear([1,3], { maxDistance : 5, spherical : true }, function(err,results, stats) {console.log(results);
    });
    

或者确保有

  1. 确保有GeoJSON数据结构

    { <location field>: { type: "<GeoJSON type>" , coordinates: <coordinates> } }
    
  2. 增加索引AttractionSchema.index({location: '2dsphere'});
  3. 查找

     // geoJsonvar point = { type : "Point", coordinates : [9,9] };Model.geoNear(point, { maxDistance : 5, spherical : true }, function(err,     results, stats) {console.log(results);});
    

扩展

利用aggregate

models.Attraction.aggregate([{"$geoNear": {// "near": {//         "type": "Point",//         "coordinates": [-74.00824900000001, 40.708635]//     },"near": [-74.00824900000001, 40.708635],"maxDistance": 10000,"distanceMultiplier": 6371,"spherical": true,"query":{cityid: '516cc44ce3c6a60f69000011'},"distanceField": "dist.calculated","includelocs":"dist.location"}},{"$skip": 10},{"$limit": 10}],function(err, docs) {if (err) {console.log(err);} else {docs.forEach(function(element, index){console.log(element.cityname + ' '+element.attractions + ' '+ element.dist.calculated);});}// These are not mongoose documents, but you can always cast them}
);


db.runCommand(
{
geoNear : "Infos" ,
near : { "type" : "Point" , "coordinates" : [113.643196,34.800495]} , 
spherical : true ,
minDistance: 0,
maxDistance: 5000,
num : 50
})

===
mongoDB支持二维空间索引,使用空间索引,mongoDB支持一种特殊查询,如某地图网站上可以查找离你最近的咖啡厅,银行等信息。这个使用mongoDB的空间索引结合特殊的查询方法很容易实现。
前提条件:
建立空间索引的key可以使用array或内嵌文档存储,但是前两个elements必须存储固定的一对空间位置数值。如
{ loc : [ 50 , 30 ] }
{ loc : { x : 50 , y : 30 } }
{ loc : { foo : 50 , y : 30 } }
{ loc : { lat : 40.739037, long: 73.992964 } }
# 使用范例1:
> db.mapinfo.drop()                                         
true
> db.mapinfo.insert({"category" : "coffee","name" : "digoal coffee bar","loc" : [70,80]})
> db.mapinfo.insert({"category" : "tea","name" : "digoal tea bar","loc" : [70,80]})      
> db.mapinfo.insert({"category" : "tea","name" : "hangzhou tea bar","loc" : [71,81]})
> db.mapinfo.insert({"category" : "coffee","name" : "hangzhou coffee bar","loc" : [71,81]})
# 未创建2d索引时,不可以使用$near进行查询
> db.mapinfo.find({loc : {$near : [50,50]}})
error: {
        "$err" : "can't find special index: 2d for: { loc: { $near: [ 50.0, 50.0 ] } }",
        "code" : 13038
}
# 在loc上面创建2d索引
> db.mapinfo.ensureIndex({"loc" : "2d"},{"background" : true})
> db.mapinfo.getIndexes()                                     
[
        {
                "name" : "_id_",
                "ns" : "test.mapinfo",
                "key" : {
                        "_id" : 1
                }
        },
        {
                "_id" : ObjectId("4d242e1f3238ba30f9ca05ad"),
                "ns" : "test.mapinfo",
                "key" : {
                        "loc" : "2d"
                },
                "name" : "loc_",
                "background" : true
        }
]
# 查询测试,返回结果按照从最近到最远的顺序排序输出.
> db.mapinfo.find({loc : {$near : [72,82]},"category" : "coffee"}).explain()
{
        "cursor" : "GeoSearchCursor",
        "nscanned" : 2,
        "nscannedObjects" : 2,
        "n" : 2,
        "millis" : 0,
        "indexBounds" : {

        }
}
> db.mapinfo.find({loc : {$near : [72,82]},"category" : "coffee"})          
{ "_id" : ObjectId("4d242dce3238ba30f9ca05ac"), "category" : "coffee", "name" : "hangzhou coffee bar", "loc" : [ 71, 81 ] }
{ "_id" : ObjectId("4d242d8b3238ba30f9ca05a9"), "category" : "coffee", "name" : "digoal coffee bar", "loc" : [ 70, 80 ] }
# 换一个经纬度后结果相反.
> db.mapinfo.find({loc : {$near : [69,69]},"category" : "coffee"})
{ "_id" : ObjectId("4d242d8b3238ba30f9ca05a9"), "category" : "coffee", "name" : "digoal coffee bar", "loc" : [ 70, 80 ] }
{ "_id" : ObjectId("4d242dce3238ba30f9ca05ac"), "category" : "coffee", "name" : "hangzhou coffee bar", "loc" : [ 71, 81 ] }
# 2d默认取值范围[-179,-179]到[180,180] 包含这两个点,超出范围将报错
> db.mapinfo.insert({"category" : "bank","name" : "china people bank","loc" : [181,181]})  
point not in range
> db.mapinfo.insert({"category" : "bank","name" : "china people bank","loc" : [-179,-180]})
in > 0
# 如果已经存在超过范围的值,建2D索引将报错
> db.mapinfo.insert({"category" : "bank","name" : "china people bank","loc" : [-180,-180]})
> db.mapinfo.ensureIndex({"loc" : "2d"})                                                   
in > 0
# 在建2d索引的时候可以指定取值范围
# 如,以上包含了[-180,-180]这个点之后,建2d索引将报错,使用以下解决.或者把这条记录先处理掉.
# 在限制条件下,min不包含,max包含,从下面建索引的语句中可以看出.
> db.mapinfo.ensureIndex({"loc" : "2d"},{min:-181,max:180})
> 成功
# 注意官方文档上说you can only have 1 geo2d index per collection right now,不过测试可以建多个,如下
> db.mapinfo.drop()                                        
true
> db.mapinfo.insert({"category" : "bank","name" : "china people bank","loc" : [71,81],"HQ_loc" : [91,101]})
> db.mapinfo.ensureIndex({"loc" : "2d"},{"background" : "true"})                                           
> db.mapinfo.ensureIndex({"HQ_loc" : "2d"},{"background" : "true"})
> db.mapinfo.getIndexes()
[
        {
                "name" : "_id_",
                "ns" : "test.mapinfo",
                "key" : {
                        "_id" : 1
                }
        },
        {
                "_id" : ObjectId("4d2439803238ba30f9ca05cd"),
                "ns" : "test.mapinfo",
                "key" : {
                        "loc" : "2d"
                },
                "name" : "loc_",
                "background" : "true"
        },
        {
                "_id" : ObjectId("4d2439863238ba30f9ca05ce"),
                "ns" : "test.mapinfo",
                "key" : {
                        "HQ_loc" : "2d"
                },
                "name" : "HQ_loc_",
                "background" : "true"
        }
]
> db.mapinfo.find({"loc" : {"$near" : [20,21]}})                                                           
{ "_id" : ObjectId("4d2439643238ba30f9ca05cc"), "category" : "bank", "name" : "china people bank", "loc" : [ 71, 81 ], "HQ_loc" : [ 91, 101 ] }
> db.mapinfo.find({"HQ_loc" : {"$near" : [20,21]}})
{ "_id" : ObjectId("4d2439643238ba30f9ca05cc"), "category" : "bank", "name" : "china people bank", "loc" : [ 71, 81 ], "HQ_loc" : [ 91, 101 ] }

# 使用范例2:
# 测试数据
> db.mapinfo.find()
{ "_id" : ObjectId("4d2439643238ba30f9ca05cc"), "category" : "bank", "name" : "china people bank", "loc" : [ 71, 81 ], "HQ_loc" : [ 91, 101 ] }
{ "_id" : ObjectId("4d243a743238ba30f9ca05cf"), "category" : "coffee", "name" : "digoal coffee bar", "loc" : [ 100, 81 ], "HQ_loc" : [ 100, 101 ] }
{ "_id" : ObjectId("4d243a8b3238ba30f9ca05d0"), "category" : "tea", "name" : "digoal tea bar", "loc" : [ 110, 81 ], "HQ_loc" : [ 110, 101 ] }
{ "_id" : ObjectId("4d243ab23238ba30f9ca05d1"), "category" : "shop", "name" : "digoal supermarket", "loc" : [ 120, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aba3238ba30f9ca05d2"), "category" : "shop", "name" : "digoal supermarket1", "loc" : [ 121, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243abe3238ba30f9ca05d3"), "category" : "shop", "name" : "digoal supermarket2", "loc" : [ 122, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243ac33238ba30f9ca05d4"), "category" : "shop", "name" : "digoal supermarket3", "loc" : [ 123, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243ac83238ba30f9ca05d5"), "category" : "shop", "name" : "digoal supermarket4", "loc" : [ 124, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243ace3238ba30f9ca05d6"), "category" : "shop", "name" : "digoal supermarket5", "loc" : [ 125, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243ad63238ba30f9ca05d7"), "category" : "shop", "name" : "digoal supermarket6", "loc" : [ 126, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aee3238ba30f9ca05d8"), "category" : "shop", "name" : "digoal supermarket7", "loc" : [ 26, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af43238ba30f9ca05d9"), "category" : "shop", "name" : "digoal supermarket8", "loc" : [ 27, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af93238ba30f9ca05da"), "category" : "shop", "name" : "digoal supermarket9", "loc" : [ 29, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aff3238ba30f9ca05db"), "category" : "shop", "name" : "digoal supermarket10", "loc" : [ 30, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243b063238ba30f9ca05dc"), "category" : "shop", "name" : "digoal supermarket11", "loc" : [ 31, 81 ], "HQ_loc" : [ 120, 101 ] }
# 索引
> db.mapinfo.getIndexes()
[
        {
                "name" : "_id_",
                "ns" : "test.mapinfo",
                "key" : {
                        "_id" : 1
                }
        },
        {
                "_id" : ObjectId("4d2439803238ba30f9ca05cd"),
                "ns" : "test.mapinfo",
                "key" : {
                        "loc" : "2d"
                },
                "name" : "loc_",
                "background" : "true"
        },
        {
                "_id" : ObjectId("4d2439863238ba30f9ca05ce"),
                "ns" : "test.mapinfo",
                "key" : {
                        "HQ_loc" : "2d"
                },
                "name" : "HQ_loc_",
                "background" : "true"
        }
]
# 查询离[50,50]最近的5家商店
> db.mapinfo.find({"loc" : {"$near" : [50,50]},"category" : "shop"}).limit(5)
{ "_id" : ObjectId("4d243b063238ba30f9ca05dc"), "category" : "shop", "name" : "digoal supermarket11", "loc" : [ 31, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aff3238ba30f9ca05db"), "category" : "shop", "name" : "digoal supermarket10", "loc" : [ 30, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af93238ba30f9ca05da"), "category" : "shop", "name" : "digoal supermarket9", "loc" : [ 29, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af43238ba30f9ca05d9"), "category" : "shop", "name" : "digoal supermarket8", "loc" : [ 27, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aee3238ba30f9ca05d8"), "category" : "shop", "name" : "digoal supermarket7", "loc" : [ 26, 81 ], "HQ_loc" : [ 120, 101 ] }
# 找出限制离[50,50]在37 的商店,使用maxDistance
> db.mapinfo.find({"loc" : {"$near" : [50,50], "$maxDistance" : 37},"category" : "shop"})
{ "_id" : ObjectId("4d243b063238ba30f9ca05dc"), "category" : "shop", "name" : "digoal supermarket11", "loc" : [ 31, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aff3238ba30f9ca05db"), "category" : "shop", "name" : "digoal supermarket10", "loc" : [ 30, 81 ], "HQ_loc" : [ 120, 101 ] }
# 复合索引
> db.mapinfo.ensureIndex({"loc" : "2d","category" : 1})                                                        
> db.mapinfo.getIndexes()
[
        {
                "name" : "_id_",
                "ns" : "test.mapinfo",
                "key" : {
                        "_id" : 1
                }
        },
        {
                "_id" : ObjectId("4d2439803238ba30f9ca05cd"),
                "ns" : "test.mapinfo",
                "key" : {
                        "loc" : "2d"
                },
                "name" : "loc_",
                "background" : "true"
        },
        {
                "_id" : ObjectId("4d2439863238ba30f9ca05ce"),
                "ns" : "test.mapinfo",
                "key" : {
                        "HQ_loc" : "2d"
                },
                "name" : "HQ_loc_",
                "background" : "true"
        },
        {
                "_id" : ObjectId("4d243ce13238ba30f9ca05dd"),
                "ns" : "test.mapinfo",
                "key" : {
                        "loc" : "2d",
                        "category" : 1
                },
                "name" : "loc__category_1"
        }
]

3. 范例 3
# 除了使用find来搜索以外,还可以使用runCommand
> db.runCommand({"geoNear" : "mapinfo","near" : [50,50],"num" : 10})
{ "errmsg" : "more than 1 geo indexes :(", "ok" : 0 }
# 这里报错,原因是mapinfo超过一个2d索引,但是使用find来查询不会报错,
# 只保留一个“2d"索引后,使用runCommand正常
> db.mapinfo.dropIndex({"loc" : "2d","category" : 1})
{ "nIndexesWas" : 4, "ok" : 1 }
> db.runCommand({"geoNear" : "mapinfo","near" : [50,50],"num" : 10})                     
{ "errmsg" : "more than 1 geo indexes :(", "ok" : 0 }
> db.mapinfo.dropIndex({"HQ_loc" : "2d"})                           
{ "nIndexesWas" : 3, "ok" : 1 }
# "num" 限制返回的记录数
# 使用runCommand和geoNear的好处是可以返回距离.本例"dis" : 36.3593194466869,
> db.runCommand({"geoNear" : "mapinfo","near" : [50,50],"num" : 1}) 
{
        "ns" : "test.mapinfo",
        "near" : "1100110000001111110000001111110000001111110000001111",
        "results" : [
                {
                        "dis" : 36.3593194466869,
                        "obj" : {
                                "_id" : ObjectId("4d243b063238ba30f9ca05dc"),
                                "category" : "shop",
                                "name" : "digoal supermarket11",
                                "loc" : [
                                        31,
                                        81
                                ],
                                "HQ_loc" : [
                                        120,
                                        101
                                ]
                        }
                }
        ],
        "stats" : {
                "time" : 0,
                "btreelocs" : 6,
                "nscanned" : 7,
                "objectsLoaded" : 3,
                "avgDistance" : 36.3593194466869,
                "maxDistance" : 36.3593194466869
        },
        "ok" : 1
}
# 使用runCommand同样也可以使用普通的FIND的限制条件,如下放在query : { "category" : "coffee" }
> db.runCommand({"geoNear" : "mapinfo","near" : [50,50],"num" : 1,query : { "category" : "coffee" }})
{
        "ns" : "test.mapinfo",
        "near" : "1100110000001111110000001111110000001111110000001111",
        "results" : [
                {
                        "dis" : 58.830266786369556,
                        "obj" : {
                                "_id" : ObjectId("4d243a743238ba30f9ca05cf"),
                                "category" : "coffee",
                                "name" : "digoal coffee bar",
                                "loc" : [
                                        100,
                                        81
                                ],
                                "HQ_loc" : [
                                        100,
                                        101
                                ]
                        }
                }
        ],
        "stats" : {
                "time" : 0,
                "btreelocs" : 15,
                "nscanned" : 15,
                "objectsLoaded" : 7,
                "avgDistance" : 58.830266786369556,
                "maxDistance" : 58.830266786369556
        },
        "ok" : 1
}

4. 范例4
# 空间索引还支持范围搜索,目前支持圆和矩阵的范围
# 使用box
> box = [[19,19],[90,90]]                                
[ [ 19, 19 ], [ 90, 90 ] ]
> db.mapinfo.find({"loc" : {"$within" : {"$box" : box}}})
{ "_id" : ObjectId("4d2439643238ba30f9ca05cc"), "category" : "bank", "name" : "china people bank", "loc" : [ 71, 81 ], "HQ_loc" : [ 91, 101 ] }
{ "_id" : ObjectId("4d243b063238ba30f9ca05dc"), "category" : "shop", "name" : "digoal supermarket11", "loc" : [ 31, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aff3238ba30f9ca05db"), "category" : "shop", "name" : "digoal supermarket10", "loc" : [ 30, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af93238ba30f9ca05da"), "category" : "shop", "name" : "digoal supermarket9", "loc" : [ 29, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af43238ba30f9ca05d9"), "category" : "shop", "name" : "digoal supermarket8", "loc" : [ 27, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aee3238ba30f9ca05d8"), "category" : "shop", "name" : "digoal supermarket7", "loc" : [ 26, 81 ], "HQ_loc" : [ 120, 101 ] }
# 使用center point and radius
> center = [29,81]
[ 29, 81 ]
> radius = 10
10
> db.mapinfo.find({"loc" : {"$within" : {"$center" : [center,radius]}}})
{ "_id" : ObjectId("4d243af93238ba30f9ca05da"), "category" : "shop", "name" : "digoal supermarket9", "loc" : [ 29, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243af43238ba30f9ca05d9"), "category" : "shop", "name" : "digoal supermarket8", "loc" : [ 27, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aff3238ba30f9ca05db"), "category" : "shop", "name" : "digoal supermarket10", "loc" : [ 30, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243b063238ba30f9ca05dc"), "category" : "shop", "name" : "digoal supermarket11", "loc" : [ 31, 81 ], "HQ_loc" : [ 120, 101 ] }
{ "_id" : ObjectId("4d243aee3238ba30f9ca05d8"), "category" : "shop", "name" : "digoal supermarket7", "loc" : [ 26, 81 ], "HQ_loc" : [ 120, 101 ] }

注意事项:
1. mongoDB处理的是平面距离,但是实际生活中如果涉及到大范围的距离搜索,可能会有偏差,因为地球是球型的。The current implementation assumes an idealized model of a flat earth, meaning that an arcdegree of latitude (y) and longitude (x) represent the same distance everywhere. This is only true at the equator where they are both about equal to 69 miles or 111km. However, at the 10gen offices at { x : -74 , y : 40.74 } one arcdegree of longitude is about 52 miles or 83 km (latitude is unchanged). This means that something 1 mile to the north would seem closer than something 1 mile to the east.
2. 2d索引目前还不支持sharding,In the meantime sharded clusters can use geospatial indexes for unsharded collections within the cluster.
3. New Spherical Model,1.7.0以后将引入新的空间模型.

其他:
The current implementation encodes geographic hash codes atop standard MongoDB b-trees. Results of $near queries are exact. The problem with geohashing is that prefix lookups don't give you exact results, especially around bit flip areas. MongoDB solves this by doing a grid by grid search after the initial prefix scan. This guarantees performance remains very high while providing correct results

转载于:https://www.cnblogs.com/jayruan/p/5423668.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/288047.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

甲骨文宣布供应链管理云平台支持LogFire仓库管理系统

本文讲的是 :甲骨文宣布供应链管理云平台支持LogFire仓库管理系统 ,【IT168 资讯】甲骨文发布了一系列对其供应链管理产品的更新&#xff0c;并表示&#xff0c;云平台现在支持去年收购LogFire的仓库管理系统(WMS)。 ▲ Oracle将在最新版本的Oracle供应链管理(SCM)Cloud产品…

i5老是显示无服务器,为什么懂电脑的人选择买i5处理器,而不是i7,背后的真实原因?...

摘要&#xff1a;我们在选购电脑的时候经常会被五花八门的型号参数看的神魂颠倒&#xff0c;有很多朋友对cpu的理解也仅限于i7一定比i5好&#xff0c;i5一定比i3好的阶段。然而&#xff0c;对于很多懂电脑的人来说&#xff0c;选购电脑时&#xff0c;都不会买i7的CPU处理器&…

python 实现装饰器设计模式

python 装饰器简单、基本的实现并不复杂。装饰器&#xff08;Decorators&#xff09;模式类似于继承&#xff0c;当你需要为某一个对象添加额外的动作、行为时&#xff0c;在不改变类的情况下可以使用装饰器。这篇文就当做一篇水文&#xff0c;本来不想写&#xff0c;因为这个专…

Excel抽奖小程序

今天分享一个用Excel制作的抽奖小程序。 如上图&#xff0c;制作一个抽奖小界面&#xff0c;滚动显示区域写入“INDIRECT("A"&RANDBETWEEN(2,13))”&#xff0c;按F9键不放&#xff0c;程序开始运行&#xff0c;松开F9键&#xff0c;抽奖完成。 函数解说&#x…

剑指offer之partition算法

1 问题 partition 算法: 从无序数组中选出枢轴点 pivot&#xff0c;然后通过一趟扫描&#xff0c;以 pivot 为分界线将数组中其他元素分为两部分&#xff0c;使得左边部分的数小于等于枢轴&#xff0c;右边部分的数大于等于枢轴&#xff08;左部分或者右部分都可能为空&#x…

让DIV中文字换行显示

让DIV中文字换行显示 1. <style>div{white-space:normal;word-break:break-all;word-wrap:break-word; }</style><div style" width:100px; border:1px solid red">I am a doibiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</div> 未加css前效果&…

WPF效果第一百八十三篇之无缝循环滚动

这不最近一直都在瞎玩Xamarin,渐渐的把WPF给冷落的;假期前突然收到一个着急的模糊不清的需求:图片无缝循环滚动;由于着急我就比较偷懒直接用了很low的方式实现了一版:1、前台就是直接Canvas嵌套StackPanel:<Canvas ClipToBounds"True" x:Name"RootCanvas&quo…

看得懂的外观设计模式 python3 实现

外观设计模式在平常的代码编写中&#xff0c;会经常使用。在平常代码的编写时&#xff0c;即使程序员没有从标准上认识过外观设计模式&#xff0c;但在开发的过程中&#xff0c;也会从代码的多方面角度考虑&#xff0c;从而编写了符合外观设计模式的代码。 很多程序员都有这种…

NuGet包管理平台

这节来讲一下.NET下的包管理平台&#xff1a;NuGet。简介我们做一个项目&#xff0c;除了自己的代码文件之外&#xff0c;实际上还要引用诸多代码文件&#xff0c;这些文件可能是我们自己封装的底层框架代码&#xff0c;或者为了完成某个功能而引用的工具类文件等等。在.NET里边…

看得懂的设计模式 享元模式python3 最基本(简单)实现

在考量系统内存合理使用时&#xff0c;通过享元模式可降低性能压力以及降低资源占用&#xff1b;主要实现是通过共享数据这一思想实现资源的合理分配。 在开发项目时&#xff0c;很多情况下会存在过多的相似对象&#xff0c;该对象有相同的共同点&#xff0c;该共同点在程序设…

creo管道设计教程_CREO/PROE产品设计教程之四芯花线建模,加深对关系式的认识...

阅读完&#xff0c;如果觉得有用&#xff0c;那么点击"关注"和点赞是对作者的一种尊重和鼓励。版权所有&#xff0c;抄袭必究。春节前&#xff0c;基本敲定和相关知名出版社在2020年的图书创作及出版计划。文&#xff1a;钟日铭我曾经介绍过三芯"花线"建模…

Qt 第一步 HelloWorld 的第一个程序

简言 Qt 是基于C的 GUI 解决方案。QT简单易学&#xff08;底层封装的好&#xff09;、跨平台、相关资料易得到。 开始写Qt 相关的文章的主要原因是&#xff0c;我本人在编写一个视频录制及相关处理的项目&#xff0c;写到一半发现.net winform 相关UI的处理限制较大&#xff…

ArcGIS 10.x属性表乱码问题解决办法

ArcGIS 10.x的版本&#xff0c;文件属性表老出现乱码的问题。 解决方法&#xff1a;在Cmd命令行中输入以下命令&#xff1a; reg add HKEY_CURRENT_USER\Software\ESRI\Desktop10.6\Common\CodePage /v dbfDefault /t REG_SZ /d 936 /f 版本找对应的该就行&#xff0c;10.2 …

SAP MM 采购订单收货被取消了还是不能增加新的delivery cost!

SAP MM 采购订单收货被取消了还是不能增加新的delivery cost! PO# 8500015169, we did GR and cancelled GR, there is no IR for this PO at present. ME22N, try to add a delivery cost ZCIP in the item, You cannot enter new delivery costs Message no. V1631 Diag…

webots仿真报警[ERROR] [1703399199.459991029]: Sampling period is not valid.

一、故障现象 在运行interace传感器使能程序时&#xff0c;报警[ERROR] [1703399199.459991029]: Sampling period is not valid. [ERROR] [1703399199.460080083]: Failed to enable lidar.并发生崩溃。 二、解决方式 1、尝试将程序中的TIME_STEP数值改为与WOrldInfo中的bas…

python3 最简单的实现 模版设计模式

在项目开发过程时&#xff0c;遇见某些子类的逻辑处理流程大致相同&#xff0c;可是用模板模式减少代码冗余&#xff0c;降低耦合。 例如实现某一窗体或者页面启动时&#xff0c;第一步需要加载启动界面图片资源&#xff0c;第二步加载个人信息&#xff0c;第三步加载个人钱包…

玩转CSS选择器(一) 之 使用方法介绍

前言 前几天整理了CSS一些技术关键字&#xff0c;但是因为自己的知识过于单薄&#xff0c;觉得考虑的不充分有欠缺&#xff0c;随后便在sf.gg提出了这个问题《关于CSS核心技术关键字都有哪些&#xff1f;》&#xff0c;也是为了让厉害的人一起参与进来&#xff0c;用他们的经验…

php基础-1

//echo "hello","aaaa";//输出语法&#xff0c;可以输出多个字符串//print "world"; //可以输出&#xff0c;只能输出一个字符串 用"."拼接可以输出&#xff0c;用","拼接直接报错 //数据类型 int,double,float,string,char…

工业相机和普通相机的区别详解_数码单反相机和胶片单反相机的区别

从相机出世到现在&#xff0c;相机的种类可以分为两种&#xff0c;一个是早期的胶片相片&#xff0c;另一个是现在的数码相机&#xff0c;数码相机的种类也是有很多种&#xff0c;其中最为常见就是单反相机了。那么今天我们就来看看胶片机和单反的区别。相机的种类总的来说可以…

ArcGIS 10.6 Data Interoperability Tools的安装与使用(附安装包下载)

ArcGIS平台中提供了一个数据交互操作工具Data Interoperability Tools,安装Desktop的时候不是一并安装的,这样导致Data Interoperability Tools工具箱下的工具(如Quick Import)全面有一个红色的叉号,无法正常使用,解决办法是手动安装Data Interoperability Tools,位于软…