Skip to content

Commit fe2928d

Browse files
committed
修复制图新建另存后符号库不显示
1 parent b539ecf commit fe2928d

12 files changed

Lines changed: 486 additions & 273 deletions

File tree

-1.66 MB
Binary file not shown.
876 KB
Binary file not shown.

‎android/app/src/main/java/com/supermap/RN/FileTools.java‎

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,16 @@ public static void unZipFile(String archive, String decompressDir, Promise promi
341341

342342

343343
@ReactMethod
344-
public static void deleteFile(String zippath, Promise promise) {
344+
public static void deleteFile(String path, Promise promise) {
345345
try {
346-
File file = new File(zippath);
346+
File file = new File(path);
347347
boolean result = false;
348348
if (file.exists()) {
349-
result = file.delete();
349+
if (file.isDirectory()) {
350+
result = deleteDirectory(path);
351+
} else {
352+
result = deleteFile(path);
353+
}
350354
}
351355
promise.resolve(result);
352356
}catch (Exception e){
@@ -535,21 +539,27 @@ public static Boolean initUserDefaultData(String userName, Context context) {
535539
userName = userName == null || userName.equals("") ? "Customer" : userName;
536540

537541
// 初始化用户工作空间
538-
String downloadsPath = SDCARD + "/iTablet/User/" + userName + "/ExternalData/";
539-
String dataPath = SDCARD + "/iTablet/User/" + userName + "/Data/";
540-
// String dataPath2 = SDCARD + "/iTablet/User/" + userName + "/Data/Scene/";
541-
String originName = "Customer.smwu";
542-
// String originName2 = "OlympicGreen_android.zip";
543-
String wsName = "Workspace.smwu";
544-
// String ssName = "OlympicGreen_android.zip";
545-
if (!Utils.fileIsExit(dataPath + wsName)) {
546-
Utils.copyAssetFileToSDcard(context.getApplicationContext(), dataPath, originName, wsName);
542+
String userPath = SDCARD + "/iTablet/User/" + userName + "/";
543+
String downloadsPath = userPath + "ExternalData/";
544+
String dataPath = userPath + "Data/";
545+
546+
String defaultData = "DefaultData";
547+
String defaultDataPath = SDCARD + "/iTablet/User/" + userName + "/" + defaultData + "/";
548+
// String originName = "Customer.smwu";
549+
String originName = "Workspace.zip";
550+
String defaultDataZip = "DefaultData.zip";
551+
String wsName = "Workspace.sxwu";
552+
553+
if (!Utils.fileIsExit(defaultDataPath + wsName)) {
554+
Utils.copyAssetFileToSDcard(context.getApplicationContext(), userPath, originName, defaultDataZip);
555+
if (Utils.fileIsExit(userPath + defaultDataZip)) {
556+
FileTools.unZipFile(userPath + defaultDataZip, defaultDataPath);
557+
}
558+
}
559+
File defaultDataFile = new File(userPath + defaultDataZip);
560+
if (defaultDataFile.exists()) {
561+
defaultDataFile.delete();
547562
}
548-
// if (!Utils.fileIsExit(dataPath2 + ssName)) {
549-
// Utils.copyAssetFileToSDcard(context.getApplicationContext(), dataPath2, originName2, ssName);
550-
// Decompressor.UnZipFolder(dataPath2 + originName2, dataPath2);
551-
// Utils.deleteFile(dataPath2 + originName2);
552-
// }
553563

554564
//创建用户目录
555565
createDirectory(dataPath + "Attribute");
@@ -682,5 +692,58 @@ public static boolean isMessyCode(String strName) {
682692
return false;
683693

684694
}
695+
696+
697+
698+
public static boolean deleteFile(String path) {
699+
File file = new File(path);
700+
boolean result = false;
701+
if (file.exists()) {
702+
if (!file.isDirectory())
703+
result = file.delete();
704+
}
705+
return result;
706+
}
707+
708+
public static boolean deleteDirectory(String path) {
709+
// 如果path不以文件分隔符结尾,自动添加文件分隔符
710+
if (!path.endsWith(File.separator))
711+
path = path + File.separator;
712+
File pathFile = new File(path);
713+
// 如果path对应的文件不存在,或者不是一个目录,则退出
714+
if ((!pathFile.exists()) || (!pathFile.isDirectory())) {
715+
System.out.println("删除目录失败:" + path + "不存在!");
716+
return false;
717+
}
718+
boolean flag = true;
719+
// 删除文件夹中的所有文件包括子目录
720+
File[] files = pathFile.listFiles();
721+
for (int i = 0; i < files.length; i++) {
722+
// 删除子文件
723+
if (files[i].isFile()) {
724+
flag = deleteFile(files[i].getAbsolutePath());
725+
if (!flag)
726+
break;
727+
}
728+
// 删除子目录
729+
else if (files[i].isDirectory()) {
730+
flag = deleteDirectory(files[i]
731+
.getAbsolutePath());
732+
if (!flag)
733+
break;
734+
}
735+
}
736+
if (!flag) {
737+
System.out.println("删除目录失败!");
738+
return false;
739+
}
740+
// 删除当前目录
741+
if (pathFile.delete()) {
742+
System.out.println("删除目录" + path + "成功!");
743+
return true;
744+
} else {
745+
return false;
746+
}
747+
}
685748
}
686749

‎ios/Tools/FileTools.m‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,22 @@ +(BOOL)initUserDefaultData:(NSString *)userName {
279279
userName = userName == nil || [userName isEqualToString:@""] ? @"Customer" : userName;
280280
281281
// 初始化用户工作空间
282-
NSString* srclic = [[NSBundle mainBundle] pathForResource:@"Customer" ofType:@"smwu"];
283-
NSString* wsPath = [NSString stringWithFormat:@"%@%@%@", @"/Documents/iTablet/User/", userName, @"/Data/" ];
284-
[FileTools createFileDirectories:[NSHomeDirectory() stringByAppendingFormat:@"%@%@", wsPath, @""]];
285-
if (srclic) {
286-
NSString* deslic = [NSHomeDirectory() stringByAppendingFormat:@"%@%@%@", wsPath, @"Workspace", @".smwu"];
287-
if(![[NSFileManager defaultManager] fileExistsAtPath:deslic isDirectory:nil]){
288-
if(![[NSFileManager defaultManager] copyItemAtPath:srclic toPath:deslic error:nil])
289-
NSLog(@"拷贝数据失败");
290-
}
282+
NSString* srclic = [[NSBundle mainBundle] pathForResource:@"Workspace" ofType:@"zip"];
283+
NSString* defaultDataPath = [NSHomeDirectory() stringByAppendingFormat:@"%@%@%@", @"/Documents/iTablet/User/", userName, @"/DefaultData/" ];
284+
NSString* wsName = @"Workspace.sxwu";
285+
286+
[FileTools createFileDirectories:[NSHomeDirectory() stringByAppendingFormat:@"%@%@", defaultDataPath, @""]];
287+
// if (srclic) {
288+
// NSString* deslic = [NSHomeDirectory() stringByAppendingFormat:@"%@%@%@", wsPath, @"Workspace", @".smwu"];
289+
// if(![[NSFileManager defaultManager] fileExistsAtPath:deslic isDirectory:nil]){
290+
// if(![[NSFileManager defaultManager] copyItemAtPath:srclic toPath:deslic error:nil])
291+
// NSLog(@"拷贝数据失败");
292+
// }
293+
// }
294+
295+
if (![[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@%@%@", defaultDataPath, @"Workspace/", wsName] isDirectory:nil]) {
296+
if(![FileTools unZipFile:srclic targetPath:defaultDataPath])
297+
NSLog(@"拷贝数据失败");
291298
}
292299
293300
//创建用户目录

‎ios/iTablet.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
0A0D938821E74EB70041B997 /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A0D938621E74B0B0041B997 /* libSplashScreen.a */; };
4242
0A15464A21D36FB800347720 /* SuperMap.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A15464921D36FB800347720 /* SuperMap.framework */; };
4343
0A15466921D719A500347720 /* libSupermap.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A15465621D710BD00347720 /* libSupermap.a */; };
44-
0A16C42C21AC0F9100A515FA /* Customer.smwu in Resources */ = {isa = PBXBuildFile; fileRef = 0A16C42B21AC0ACF00A515FA /* Customer.smwu */; };
4544
0A177FE721F0A8B900EA39D6 /* resources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 0A177FBC21F0A8B900EA39D6 /* resources.bundle */; };
45+
0A177FE921F7092E00EA39D6 /* Workspace.zip in Resources */ = {isa = PBXBuildFile; fileRef = 0A177FE821F7092D00EA39D6 /* Workspace.zip */; };
4646
0A8EEE0A21104C7100F206BB /* SuperMap.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 0A8EEDF221104C7100F206BB /* SuperMap.bundle */; };
4747
0A8EEE0B21104C7100F206BB /* libAsHttpRequest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A8EEDF321104C7100F206BB /* libAsHttpRequest.a */; };
4848
0A8EEE0C21104C7100F206BB /* libCorePlot.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A8EEDF421104C7100F206BB /* libCorePlot.a */; };
@@ -450,8 +450,8 @@
450450
0A0A2033212FA22300BEBC1C /* 选中.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "选中.png"; sourceTree = "<group>"; };
451451
0A15464921D36FB800347720 /* SuperMap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SuperMap.framework; path = iPhoneOS.sdk/SuperMap.framework; sourceTree = "<group>"; };
452452
0A15465121D710BD00347720 /* Supermap.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Supermap.xcodeproj; path = ../node_modules/imobile_for_reactnative/ios/Supermap.xcodeproj; sourceTree = "<group>"; };
453-
0A16C42B21AC0ACF00A515FA /* Customer.smwu */ = {isa = PBXFileReference; lastKnownFileType = file; path = Customer.smwu; sourceTree = "<group>"; };
454453
0A177FBC21F0A8B900EA39D6 /* resources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = resources.bundle; sourceTree = "<group>"; };
454+
0A177FE821F7092D00EA39D6 /* Workspace.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = Workspace.zip; sourceTree = "<group>"; };
455455
0A8EEDF221104C7100F206BB /* SuperMap.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = SuperMap.bundle; path = ../../iTablet/ios/iPhoneOS.sdk/SuperMap.framework/Versions/A/Resources/SuperMap.bundle; sourceTree = "<group>"; };
456456
0A8EEDF321104C7100F206BB /* libAsHttpRequest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libAsHttpRequest.a; path = ../../iTablet/ios/iPhoneOS.sdk/SuperMap.framework/Versions/A/Resources/ThirdLib/libAsHttpRequest.a; sourceTree = "<group>"; };
457457
0A8EEDF421104C7100F206BB /* libCorePlot.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libCorePlot.a; path = ../../iTablet/ios/iPhoneOS.sdk/SuperMap.framework/Versions/A/Resources/ThirdLib/libCorePlot.a; sourceTree = "<group>"; };
@@ -699,8 +699,8 @@
699699
0A16C40221AC0AB700A515FA /* assets */ = {
700700
isa = PBXGroup;
701701
children = (
702+
0A177FE821F7092D00EA39D6 /* Workspace.zip */,
702703
0A177FBC21F0A8B900EA39D6 /* resources.bundle */,
703-
0A16C42B21AC0ACF00A515FA /* Customer.smwu */,
704704
);
705705
path = assets;
706706
sourceTree = "<group>";
@@ -1412,7 +1412,6 @@
14121412
0A0A2041212FA22300BEBC1C /* 密度图-当前.png in Resources */,
14131413
0A0A204D212FA22300BEBC1C /* 选中.png in Resources */,
14141414
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
1415-
0A16C42C21AC0F9100A515FA /* Customer.smwu in Resources */,
14161415
0A0A203B212FA22300BEBC1C /* 图表-当前.png in Resources */,
14171416
0A0A203C212FA22300BEBC1C /* 图表-选中.png in Resources */,
14181417
D877B55B21338D850044AE61 /* Trial_License.slm in Resources */,
@@ -1434,6 +1433,7 @@
14341433
0A0A2046212FA22300BEBC1C /* 格网热度图-选中.png in Resources */,
14351434
0A0A2043212FA22300BEBC1C /* 时空数据-当前.png in Resources */,
14361435
0A0A203E212FA22300BEBC1C /* 图-收起.png in Resources */,
1436+
0A177FE921F7092E00EA39D6 /* Workspace.zip in Resources */,
14371437
0A0A203D212FA22300BEBC1C /* 图-展开.png in Resources */,
14381438
0A0A204C212FA22300BEBC1C /* 背景尾加一个.png in Resources */,
14391439
);

‎ios/iTablet/AppDelegate.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2727
NSURL *jsCodeLocation;
2828

2929
#if DEBUG
30-
[[RCTBundleURLProvider sharedSettings] setJsLocation:@"192.168.0.119"];
30+
[[RCTBundleURLProvider sharedSettings] setJsLocation:@"192.168.0.102"];
3131
#endif
3232
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
3333

‎src/constants/ConstInfo.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ export default {
5050

5151
ADD_SUCCESS: '添加成功',
5252
ADD_FAILED: '添加成功',
53+
54+
READING_DATA: '读取数据中',
5355
}

‎src/constants/ConstPath.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const AppPath = '/iTablet/'
22
const Data = 'Data/'
3+
const DefaultData = 'DefaultData/'
34
const Collection = 'Collection'
45
const MapEdit = 'MapEdit'
56
const MapTheme = 'Map/MapTheme'
7+
const Workspace = 'Workspace.sxwu' // 工作空间
68

79
const Module = {
810
Collection,
@@ -27,7 +29,11 @@ const RelativePath = {
2729
}
2830

2931
const RelativeFilePath = {
30-
Workspace: Data + 'Workspace.smwu', // 工作空间
32+
WorkspaceFile: Workspace,
33+
// Workspace: Data + 'Workspace.smwu', // 工作空间
34+
DefaultData: DefaultData, // 默认数据文件夹目录
35+
DefaultWorkspaceDir: DefaultData + 'Workspace/', // 工作空间默认数据文件夹目录
36+
Workspace: DefaultData + 'Workspace/Workspace.sxwu', // 工作空间
3137
Scene: Data + 'Scene/',
3238
List: Data + 'Scene/List/',
3339
Map: Data + 'Map/',

‎src/containers/workspace/components/ToolBar/MoreData.js‎

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/**
22
* 获取地图更多
33
*/
4-
import { ConstToolType, ConstInfo } from '../../../../constants'
4+
import { ConstToolType, ConstInfo, ConstPath } from '../../../../constants'
55
import { Toast } from '../../../../utils'
6+
import { FileTools } from '../../../../native'
67
// import NavigationService from '../../../NavigationService'
78
import constants from '../../constants'
89

@@ -135,28 +136,47 @@ function shareMap() {
135136

136137
/** 导出地图 **/
137138
function exportMap() {
138-
if (!_params.map.currentMap.name) {
139-
Toast.show(ConstInfo.PLEASE_SAVE_MAP)
140-
return
141-
}
142-
if (exporting) {
143-
Toast.show(ConstInfo.WAITING_FOR_EXPORTING_MAP)
144-
return
145-
}
146-
Toast.show(ConstInfo.EXPORTING_MAP)
147-
_params.exportWorkspace(
148-
{
149-
maps: [_params.map.currentMap.name],
150-
},
151-
(result, path) => {
152-
Toast.show(
153-
result && path
154-
? ConstInfo.EXPORT_WORKSPACE_SUCCESS
155-
: ConstInfo.EXPORT_WORKSPACE_FAILED,
156-
)
157-
exporting = false
158-
},
159-
)
139+
(async function() {
140+
if (!_params.map.currentMap.name) {
141+
Toast.show(ConstInfo.PLEASE_SAVE_MAP)
142+
return
143+
}
144+
if (exporting) {
145+
Toast.show(ConstInfo.WAITING_FOR_EXPORTING_MAP)
146+
return
147+
}
148+
Toast.show(ConstInfo.EXPORTING_MAP)
149+
let userName = _params.user.currentUser.userName || 'Customer'
150+
let mapName = _params.map.currentMap.name
151+
let fileName = _params.map.workspace.server.substr(
152+
_params.map.workspace.server.lastIndexOf('/') + 1,
153+
)
154+
let fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf('.'))
155+
let outPath = await FileTools.appendingHomeDirectory(
156+
ConstPath.UserPath +
157+
userName +
158+
'/' +
159+
ConstPath.RelativePath.ExternalData +
160+
fileNameWithoutExtension +
161+
'/' +
162+
fileName,
163+
)
164+
_params.exportWorkspace(
165+
{
166+
maps: [mapName],
167+
outPath,
168+
fileReplace: true,
169+
},
170+
(result, path) => {
171+
Toast.show(
172+
result && path
173+
? ConstInfo.EXPORT_WORKSPACE_SUCCESS
174+
: ConstInfo.EXPORT_WORKSPACE_FAILED,
175+
)
176+
exporting = false
177+
},
178+
)
179+
}.bind(this)())
160180
}
161181

162182
function shareMap3D() {

‎src/containers/workspace/components/ToolBar/StartData.js‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,33 @@ function create() {
545545
GLOBAL.Type === constants.MAP_THEME
546546
) {
547547
(async function() {
548-
await _params.setCurrentMap()
549-
await SMap.removeAllLayer() // 移除所有图层
550-
await SMap.closeDatasource(-1) // 关闭所有数据源
548+
await _params.closeMap()
549+
550+
let userPath =
551+
ConstPath.UserPath +
552+
(_params.user.currentUser.userName || 'Customer') +
553+
'/'
554+
let fillLibPath = await FileTools.appendingHomeDirectory(
555+
userPath +
556+
ConstPath.RelativeFilePath.DefaultWorkspaceDir +
557+
'Workspace.bru',
558+
)
559+
let lineLibPath = await FileTools.appendingHomeDirectory(
560+
userPath +
561+
ConstPath.RelativeFilePath.DefaultWorkspaceDir +
562+
'Workspace.lsl',
563+
)
564+
let markerLibPath = await FileTools.appendingHomeDirectory(
565+
userPath +
566+
ConstPath.RelativeFilePath.DefaultWorkspaceDir +
567+
'Workspace.sym',
568+
)
569+
await SMap.importSymbolLibrary(fillLibPath) // 导入面符号库
570+
await SMap.importSymbolLibrary(lineLibPath) // 导入线符号库
571+
await SMap.importSymbolLibrary(markerLibPath) // 导入点符号库
572+
// await _params.setCurrentMap()
573+
// await SMap.removeAllLayer() // 移除所有图层
574+
// await SMap.closeDatasource(-1) // 关闭所有数据源
551575
}.bind(this)())
552576
}
553577
}

0 commit comments

Comments
 (0)