我有多边形集.在这个集合中,一些是外部多边形,一些可能(或可能不是)是孔.我不知道在这个阶段哪个是多边形孔.我想计算包含所有多边形的最终多边形,包括孔.
我想到了这种方法:
//'SomeLib' that has polygon boolean fucntions
var polygonSet = [poly1,poly2,...polyn];
var union, intersection;
var combinedPoly = SomeLib.XOR(polygonSet[0], polygonSet[1]);
for( var i=2; i<polygonSet.length ; i++) {
combinedPoly = SomeLib.XOR(combinedPoly, polygonSet[i]);
//or if XOR is not available
union = SomeLib.union(combinedPoly, polygonSet[i]);
intersection = SomeLib.intersection(combinedPoly, polygonSet[i]);
combinedPoly = union - intersection;
}
Run Code Online (Sandbox Code Playgroud)
所以我对模块的要求是
我所遇到的图书馆清单以及我理解的一些要点:
我在单机上使用websockets/ws 。它工作正常。我想在多核和多个实例上水平扩展它。对于多核,我尝试使用pm2,它似乎工作得很好。
第一个问题:这是最好的方法还是合适的方法?这是我使用 pm2 的测试代码
// ws-server.js
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 3131 });
var pid = process.pid + ''
console.log('process pid: '+ pid)
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
if (message === 'get-pid') {
ws.send('pid-' + pid)
} else {
var matched = pid === message ? 'old friends' : 'strangers'
ws.send([pid, message, 'we are ' + matched].join(', '))
}
});
ws.send('first time')
});
Run Code Online (Sandbox Code Playgroud)
和客户端 websocket 实例
// …Run Code Online (Sandbox Code Playgroud) 我正在使用php-excel-reader,但在阅读.xlsx文件时出错.这也支持xlsx格式.或者其他解决方案是什么.
我的要求只是阅读文件(xls, xlsx and ods)并在html页面上呈现.
PHPExcel 似乎太多了,因为不需要编辑excel文件.
我正在创建XMLHttpRequest javascript模块以从服务器获取JSON数据.这是代码:
(function() {
var makeRequest = function(url,callback,opt) {
var xhr;
if (XMLHttpRequest) { // Mozilla, Safari, ...
xhr = new XMLHttpRequest();
} else if (ActiveXObject) { // IE
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!xhr) {
callback.call(this,
'Giving up :( Cannot create an XMLHTTP instance',
null);
return false;
}
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) …Run Code Online (Sandbox Code Playgroud) 我是第一次使用ZODB.只是尝试使用FileStorage提交数据.但是当我第二次执行相同的脚本时,我无法提交新对象.这是我的剧本
from ZODB import FileStorage,DB
import transaction
storage = FileStorage.FileStorage('/tmp/test.fs')
db = DB(storage)
conn = db.open()
root = conn.root()
#root['layer']={}
root['layer']['2b']={"id":'2b','name':'some name'}
transaction.commit()
conn.close()
db.close()
storage.close()
Run Code Online (Sandbox Code Playgroud)
当我再次重复代码时,只需更改id root['layer']['2c']并从python中退出,第二次对象就不会被提交.我只有第一个对象.可能是什么原因.
javascript ×2
node.js ×2
excel ×1
geometry ×1
intersection ×1
mocha.js ×1
node-cluster ×1
php ×1
pm2 ×1
polygon ×1
python ×1
sinon ×1
svg ×1
websocket ×1
zodb ×1