Tag Archives: utility

GeneratePolygonsByPoints utility

Purpose: to generate polygons (rectangles) by connecting neighboring points

Author: Zhuotong Nan
Email: [email protected]
Date: Nov 21, 2007

ver: 1.0.0

Usage: GeneratePolygonsByPoints [data_file_name] {output shapefile name}
Rows*Cols (for ex, 260*250): (enter numbers of rows and cols for the source data file with
a format rows*cols. Incorrect input will stop the tool.)

data_file_name: source data file name; path can be included.
output shapefile name: optional, as its literal stated. path can be includes.

Supporting environment: Microsoft dotnet framework 2.0, ArcGIS 9.2 with dotnet assemblies, as
well as a valid ArcInfo license.

Remarks: Data file should be organized row by row (you should know exact row and column
number, which will be required to be entered after starting), starting from lower left corner.
In my initial case, the data file is generated by a modified Read_XMRG2 utility for XMRG
radar data file. The modified Read_XMRG2 will generate data with geographical coordinates
instead of HRAP coordinates as does original Read_XMRG2. Anyway, GeneratePolygonsByPoints
will also run against data file generated by original Read_XMRG2, however, with output
shapefile being in HRAP coordination.

Data file content looks like following:

-121.177570 37.897155 0.000000
-121.132468 37.907464 0.000000
-121.087345 37.917746 0.000000
-121.042201 37.928001 0.000000
-120.997037 37.938229 0.000000

The first column is longitude, second latitude, and the third precipitation value. The first
two columns represent that cells’ lower left coordinations. The first row indicates the lower
left cell; second is the next cell right to the first cell; after finishing a row, then begin
a row up the first row, and move upwards.

Output shapefile will be of geographic NAD83 datum. The first two columns will be converted
to points’ geographic location. Values (precp value in above example) will be lost. A new
field named "Index" will be generated to record this polygon’s lower left corner’s coordination
with a format of "lat_lon", for ex. 37.897155_-121.177570 for the first created cell. However,
you cannot depend on this field to link original source data file. In order to do link, you can
"ID" field in shapefile attribute table, which increases by one in consitence with source data
file.

As stated above, each cell is referred by its lower left corner’s coordination. The most upper
cells cannot be generated due to missing of necessary points (we only have lower edge’s
coord). Likewise, the most right cells are also missed.

The distribution also includes a test data file: xmrg0101199900z.out, with a 39*48 (rows*cols)
dimension.

For more information, please contact the author at [email protected]

完成了gimms-clip

作为了一个Qt的训练,主要是完成一个GIMMS数据集(ftp://ftp.glcf.umiacs.umd.edu/glcf/GIMMS/)的空间裁剪功能,特色在于:
  • Qt实现跨平台,国际化等功能
  • 调用GDAL完成多种GIS格式的转换
  • 可变线程来处理整个裁剪流程

完成了v1.0,可能暂时到止,以后有兴趣了,可以在此基础上再增加一些小功能,比如引进xml,将用户的配置记住等等(当然可以用QSettings,但锻炼一下学生的xml也是不错的)

放一个截图吧,已经本地化

 

——

前面有朋友问为什么在windows下不用mfc,我最早应该是mfc出身的,但接触的科研项目大多对操作平台有要求,国外很多学者仍是用linux/unix环境来进行科学研究,于是开始寻找一种可以跨平台的而且对于我来讲比较易学的工具(c/c++/c#背景),Qt当然是个不错的选择,只是Qt/win稍贵了一些

这两天写了个小玩意citationSearch v0.1

目的:
从http://sdb.csdl.ac.cn 输入文章标题和作者名,获取该文章的引用次数,以及所属
的单位名
这个小玩意初步实现了批处理的功能,比如手上有1万个文章标题和对应的作者,就可
以用这个很容易的得到引用次数等信息
技术:
Qt 4.1,
当前版本,v0.1,由于这两天 sdb.csdl.ac.cn网络有问题,所以完成界面后没有来得
及测试;几个重要类是2天前在console模式下测试通过。不过最主要的难点都已经解
决,其余的就是如何做的更好的事情了。
可以学到:
* 大量的使用了qt的signal/slot机制,这种机制对写的人很方便,但对阅读的人估计
就感觉比较乱了
* QHttp的异步机制,在http返回前,QHttp对象一定不能已经销毁
* 由于QHttp的异步机制,所以程序里 顺序的渠道是无法知道什么时候http返回信息,
这样对由几个页面组织在一起,即第二页面必须在第一页面完成后才能执行,第三个页
面,又只能在第二个页面完成后执行,必须也要通过signal来通知。即第一个页面完成
任务后,通知第二页面开始工作。
* 学到了一点新知识:一个对象发出了 signal,联结到一个对象的slot,这个slot如
果企图要删除发出signal的对象时,会出错。 这种情况在此程序里出现,即我给定一
对文章标题和作者,要求执行三个页面,得到引用次数,,在得到引用次数后,这个对
象发出signal,要求联系的slot,继续给出下一对标题和作者 ,重新开始;由于异步
机制,这个对象必须是以指针的形式给出(如果是局部变量,可能会在异步返回前,这
个对象已经销毁),所以 在重新new一个对象时,必须要删除前一个已经存在的该对
象,在slot里直接删除会出错,提示QMutex共享冲突。 试了很长时间,找到一个折衷
的解决方案:
即在重新new一个对象前,将前一个对象指针先保存起来,这样就是说 在当前的slot里
不去删除该对象,但在经过一次循环后,在下一次,可以将该对象指针完全删除,而不
引用异常。
描述的比较抽象,看一些示例代码:
entry point:

aQuery=new queryCitation(author, title, this);

aQuery->setTimeout(timeout);
connect(aQuery, SIGNAL(stopped(QString)), this,
      SLOT(saveResultsAndNextQuery(QString)));
aQuery->query();

saveResultsAndNextQuery(QString):

delete preQuery; //即在下一次调用里 删除上一次的instance
preQuery=aQuery;

aQuery=new queryCitation(author, title, this);
aQuery->setTimeout(timeout);
connect(aQuery, SIGNAL(stopped(QString)), this,
     SLOT(saveResultsAndNextQuery(QString)));
aQuery->query();

* 要形成post data,看源网页的代码,很费劲,这时可以用sniffer pro等来capture
这些post data
* 正则表达式的应用,用于抓取html文件里的需要的信息

下面给出page的基础类,供具备 post data功能的页面继承
web page页的abstract class 附下,

#pragma once
#include <QObject>
#include <QFile>
#include <QHttp>

class QTimer;

class page :
public QObject
{
    Q_OBJECT
public:
page(QString output_filename, int timeout=300);
virtual ~page(void);
virtual void PostData(); //提交数据
void setTimeOut(int secs);
public slots:
virtual void abort(); //强行取消,如超时
private:
virtual QString formatPostData()=0; //根据必要参数形成post数据,保存
                                             //在 postData里,返回值没经过url 编码
private slots:
virtual void on_postFinished(int id, bool error)=0;
/*
与QHttp.requestFinished相连
注意不要与 QHttp.done相连,Qhttp.done在
QHttp.abort或delete http时都会发生
*/
signals:
void done(bool error, QString msg); //http response 结束时发生, 无论
                                                  //有无错误
protected:
QByteArray postData;
QFile receivedHtml;
QHttp http;
QTimer* timer;
};

附界面截图

改进的图像校验码生成算法和辅助工具

*******************************************
目的
*******************************************
生成图像校验码

*******************************************    
内容           
                               

*******************************************
包括改进的asp图像检验码生成程序,和一个生成body.fix和head.fix的
辅助工具。该辅助工具基于Qt 4开发,基于GNU/GPL协议(请阅读GPL.txt
文档)。附源码。

*******************************************    
USAGE                                        

*******************************************
1. 制作0.bmp, 1.bmp等10张数字图片,并以0.bmp, 1.bmp这样的规律命名
2. 将图片放在images目录下
3. 运行tool.exe
4. 选定“生成Body.fix”,单击“运行”
5. 选定“生成head.fix”,指定检验码位数,宽度和高度是由上一步骤自动
读取得到,如果正确,保持不变。单击“运行”
6. 这时得到body.fix和head.fix,退出。
7. 用文本编辑器打开 valCode_new.asp,修改digit_width、digit_height、
digit_num 这三个参数,使之与以上步骤使用的参数一致
8. 将test.html, valCode_new.asp, body.fix, head.fix,以及blank.bin
五个文件复制到IIS虚拟目录下
9. 在浏览器里浏览test.html,就可以得到预想效果

NOTE: images目录下已经放了示例数字图片。注意每个图片大小必须严格一
致。将valCode_new.asp整合到某一web程序时,可以使用
Session("ValidationCode")对request值进行检验。

*******************************************
FILE LIST
*******************************************

blank.bin
body.fix      
head.fix      
images         <dir>
msvcp71.dll   
msvcr71.dll   
numCode.asp   
QtCore4.dll   
QtGui4.dll    
README        
src            <dir>
test.html     
tool.exe      
tool_zh.qm    
valCode_new.asp

images
0.bmp
1.bmp
2.bmp
3.bmp
4.bmp
5.bmp
6.bmp
7.bmp
8.bmp
9.bmp

src
GPL.txt
main.cpp
tool.cpp
tool.h 
tool.ico
tool.pri
tool.pro
tool.ui          

*******************************************    
CREDIT                                       

*******************************************
valCode_new.asp在BlueIdea.COM Web Team V37 2003-7-25工作的基础
改善完成(所附的numCode.asp是原文件)。
Qt是Trolltech的trademark。

Pm v2.23

仍没有帮助,有时间的朋友可以帮我写,我目前是补不上了,没有时间
也没有中文界面,既然是帮助大家学英语的,界面上的这点英语不算什么大问题吧,
如果有英语错误请帮我指出来
 
v2.2.3 [Sep-08-05]
# fixed typing a dir path in destination dir of pm tools will activate the Apply button when selecting either the backup or the restore option.
+ new Phrase Memo v2 toolkit, functioning with rebuild, back up and restore backed databases.
 
v2.2.2 [Aug-26-05]
# recompiled QtGui4.dll, to fix a popup menu bug which make menu cannot show on the taskbar.
+ singleton support.
+ double clicking the tray icon will bring up the window.
+ added system tray support. Now minimizing behavior will cause the windows hidden into system tray.
* rearrange the context menu of text edit.
# fixed when reverse selecting an underlined text then move the cursor to unformated text, the underline button will not changed simultaneously.
# fixed the cursor still keeps visible changed to read only mode.
* the cursor keep in the same position on save
 
附两个截图
下载请到 http://503.mygis.org,进去后,进入tags/rls-mmdd/,mmdd表示build的日期,选择离现在最近的日期,进入该目录,请下载 *_setup.exe。如果需要验证其合法性,请下载*_setup_md5.txt,内含该可执行文件的md5 hash码。你如果认为你的朋友也能用,just feel free to distribute it.
用户密码按已知的来,没有的请给我写信 giscn_at_msn[dot]com

pm v2.21

一个用于帮助摘录和回忆英文句子的小软件,占系统资源极小,启动极快。目的单一,就是对研究生撰写英文科技文章有帮助,帮助多少,看你自己的利用程度了,至少对于我本人来讲,很实用的东西。
没有帮助文档,没有中文界面,我只是业余抽空改改这个东西,没有计划整成一个商业的东西,sorry,这些要求概不理会,这么简单的没几个按钮,自己多试试就搞定了。
有Bug和评论的当然可以写信到 giscn_at_msn_dot_com,下载Url也请写信到此地址,自有回复。谢谢大家关心。

v2.2.1 [Jul-17-05]
# fix: when change the screen font size, an asterisk mark will show and save action activated.
# fix: the anno will save as the last line regardless of the last being
blank. Now the anno will be saved as the last non-blank line.
# fixed when closing the app with unsaved modification, clicking no will also exit the app.
# fixed search control cannot type in quote marks (")
+ added a button to adjust the font size
+ added a search functionality in the context menu
* other improvements

pm v22 release

Do you have read many of native English articles, and find many of good
English sentences?  Do you suffer the pain that when you start to
composite your English article, you forget how to express your idea in
a native manner, despite the sentence seems very familiar to you? ok,
this is very you want. this software is specially designed to  back
your English sentences you met during your reading, and will help you
much to article composition.

it’s the first time open to the Internet public.

I have attached some screenshots below. If it’s you are interested,
please drop me an email, or let me know by whatever ways you can, I
will send you an Url for download.

Bug reports , comments , or suggestions, should be send to [email protected]