java sim_Java SimMap.translate方法代码示例

import movement.map.SimMap; //导入方法依赖的package包/类

/**

* Reads a sim map from location set to the settings, mirrors the map and

* moves its upper left corner to origo.

* @return A new SimMap based on the settings

*/

private SimMap readMap() {

SimMap simMap;

Settings settings = new Settings(MAP_BASE_MOVEMENT_NS);

WKTMapReader r = new WKTMapReader(true);

if (cachedMap == null) {

cachedMapFiles = new ArrayList(); // no cache present

}

else { // something in cache

// check out if previously asked map was asked again

SimMap cached = checkCache(settings);

if (cached != null) {

nrofMapFilesRead = cachedMapFiles.size();

return cached; // we had right map cached -> return it

}

else { // no hit -> reset cache

cachedMapFiles = new ArrayList();

cachedMap = null;

}

}

try {

int nrofMapFiles = settings.getInt(NROF_FILES_S);

for (int i = 1; i <= nrofMapFiles; i++ ) {

String pathFile = settings.getSetting(FILE_S + i);

cachedMapFiles.add(pathFile);

r.addPaths(new File(pathFile), i);

}

nrofMapFilesRead = nrofMapFiles;

} catch (IOException e) {

throw new SimError(e.toString(),e);

}

simMap = r.getMap();

checkMapConnectedness(simMap.getNodes());

// mirrors the map (y' = -y) and moves its upper left corner to origo

simMap.mirror();

Coord offset = simMap.getMinBound().clone();

simMap.translate(-offset.getX(), -offset.getY());

checkCoordValidity(simMap.getNodes());

cachedMap = simMap;

return simMap;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值