Compare commits
2 Commits
35d14a481c
...
63241381a7
Author | SHA1 | Date |
---|---|---|
|
63241381a7 | 9 months ago |
|
6fbbdb4342 | 9 months ago |
9 changed files with 1756 additions and 40 deletions
@ -0,0 +1,178 @@ |
||||
package com.project.survey.ui.instrument.coordinatesystem; |
||||
|
||||
import android.content.Context; |
||||
import android.content.Intent; |
||||
import android.os.Bundle; |
||||
import android.view.KeyEvent; |
||||
import android.view.Menu; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
|
||||
import androidx.annotation.Nullable; |
||||
import androidx.appcompat.widget.Toolbar; |
||||
import androidx.fragment.app.Fragment; |
||||
import androidx.fragment.app.FragmentActivity; |
||||
|
||||
import com.bingce.activity.AutoLandscapeBingCeActivity; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.AbstractCoordinateSystemContainerFragment; |
||||
import com.bingce.device.ui.databinding.ActivityCoordinateSystemBinding; |
||||
import com.bingce.utils.ActivityUtils; |
||||
import com.bingce.utils.IntentUtil; |
||||
import com.bingce.utils.StringUtil; |
||||
import com.project.survey.R; |
||||
import com.project.survey.ui.instrument.coordinatesystem.fragment.CoordinateSystemContainerFragment; |
||||
|
||||
import blankj.utilcode.util.Utils; |
||||
|
||||
|
||||
public class BingCeCoordinateSystemActivity extends AutoLandscapeBingCeActivity { |
||||
@Override |
||||
protected void onBingCeCreate(@Nullable Bundle savedInstanceState) { |
||||
ActivityCoordinateSystemBinding binding = ActivityCoordinateSystemBinding.inflate(getLayoutInflater()); |
||||
setContentView(binding.getRoot()); |
||||
Toolbar mToolbar = findViewById(R.id.toolbar); |
||||
setSupportActionBar(mToolbar); |
||||
if (getSupportActionBar() != null) |
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||
|
||||
boolean isReturnSys = getIntent().getBooleanExtra(CoordinateSystemContainerFragment.KEY_RETURN_SYS, false); |
||||
if (isReturnSys) { |
||||
binding.activityCoordinateSystemBtnCalc.setVisibility(View.GONE); |
||||
} |
||||
|
||||
Fragment coordinatorFragment = null; |
||||
if (getIntent() != null && getIntent().getExtras() != null) { |
||||
coordinatorFragment = CoordinateSystemContainerFragment.newInstance(getIntent().getExtras()); |
||||
String title = getIntent().getStringExtra(CoordinateSystemContainerFragment.KEY_TITLE); |
||||
if (title != null && !title.isEmpty()) { |
||||
setTitle(title); |
||||
} |
||||
} |
||||
|
||||
if (coordinatorFragment == null) { |
||||
coordinatorFragment = new CoordinateSystemContainerFragment(); |
||||
} |
||||
|
||||
getSupportFragmentManager() |
||||
.beginTransaction() |
||||
.add(R.id.activity_coordinate_system_fragment, coordinatorFragment) |
||||
.commit(); |
||||
|
||||
Fragment finalCoordinatorFragment = coordinatorFragment; |
||||
binding.activityCoordinateSystemBtnQuit.setOnClickListener(v -> { |
||||
//退出
|
||||
if (finalCoordinatorFragment instanceof CoordinateSystemContainerFragment) { |
||||
((CoordinateSystemContainerFragment) finalCoordinatorFragment).onQuitClicked(); |
||||
} |
||||
}); |
||||
|
||||
binding.activityCoordinateSystemBtnAccept.setOnClickListener(v -> { |
||||
//接受
|
||||
if (finalCoordinatorFragment instanceof CoordinateSystemContainerFragment) { |
||||
((CoordinateSystemContainerFragment) finalCoordinatorFragment).onAcceptClicked(); |
||||
} |
||||
}); |
||||
|
||||
binding.activityCoordinateSystemBtnCalc.setOnClickListener(v -> { |
||||
//参数解算
|
||||
if (finalCoordinatorFragment instanceof CoordinateSystemContainerFragment) { |
||||
((CoordinateSystemContainerFragment) finalCoordinatorFragment).onCalcClicked(); |
||||
} |
||||
}); |
||||
|
||||
boolean isReadOnly = IntentUtil.boolExtra(getIntent(), CoordinateSystemContainerFragment.KEY_READ_ONLY); |
||||
binding.bottomLayout.setVisibility(isReadOnly ? View.GONE : View.VISIBLE); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onCreateOptionsMenu(Menu menu) { |
||||
// getMenuInflater().inflate(R.menu.menu_activity_rtk_coordinate_system, menu);
|
||||
return super.onCreateOptionsMenu(menu); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(MenuItem item) { |
||||
int itemId = item.getItemId(); |
||||
if (itemId == android.R.id.home) { |
||||
finish(); |
||||
} else if (itemId == R.id.menu_help) { |
||||
if (Utils.getApp() instanceof IHelper) { |
||||
((IHelper) Utils.getApp()).onNavigation2CoordinateSystemHelp(); |
||||
} |
||||
} |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onKeyDown(int keyCode, KeyEvent event) { |
||||
switch (keyCode) { |
||||
case KeyEvent.KEYCODE_BACK: |
||||
finish(); |
||||
break; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 查看并修改当前坐标系,并且直接跳转到椭球参数页面 |
||||
*/ |
||||
public static void skip2ProjViewAndModifyCurrentCoordinateSystem(Context context) { |
||||
Intent intent = IntentUtil.forceStaticMethodIntent(context, BingCeCoordinateSystemActivity.class); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_READ_ONLY, false); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_RETURN_SYS, false); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_SKIP2PROJ, true); |
||||
context.startActivity(intent); |
||||
} |
||||
|
||||
/** |
||||
* 查看坐标系,不能修改 |
||||
*/ |
||||
public static void view(Context context, String title, String jsonString) { |
||||
Intent intent = IntentUtil.forceStaticMethodIntent(context, BingCeCoordinateSystemActivity.class); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_TITLE, title); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_TXT, jsonString); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_READ_ONLY, true); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_RETURN_SYS, false); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_SKIP2PROJ, false); |
||||
context.startActivity(intent); |
||||
} |
||||
|
||||
/** |
||||
* 查看并修改当前坐标系 |
||||
*/ |
||||
public static void viewAndModifyCurrentCoordinateSystem(Context context) { |
||||
Intent intent = IntentUtil.forceStaticMethodIntent(context, BingCeCoordinateSystemActivity.class); |
||||
context.startActivity(intent); |
||||
} |
||||
|
||||
/** |
||||
* 选择「预设」的坐标系后,进入其详情界面尝试修改,然后返回修改后的json值 |
||||
*/ |
||||
public static void modifyPresetCoordinateSystemBeforeReturn( |
||||
FragmentActivity context, String jsonString, String coordinateSystemName, |
||||
boolean readonly, boolean returnSys, ICoordinateSystem coordinateSystem) { |
||||
Intent intent = IntentUtil.forceStaticMethodIntent(context, BingCeCoordinateSystemActivity.class); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_TITLE, coordinateSystemName); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_TXT, jsonString); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_READ_ONLY, readonly); |
||||
intent.putExtra(CoordinateSystemContainerFragment.KEY_RETURN_SYS, returnSys); |
||||
|
||||
ActivityUtils.startActivityForResults(context, intent, result -> { |
||||
if (result != null && result.getResultCode() == RESULT_OK) { |
||||
Intent data = result.getData(); |
||||
String json = data == null ? null : data.getStringExtra(AbstractCoordinateSystemContainerFragment.KEY_TXT); |
||||
if (coordinateSystem != null && !StringUtil.isEmpty(json)) { |
||||
coordinateSystem.onGetCoordinateSystemJson(json); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public interface ICoordinateSystem { |
||||
void onGetCoordinateSystemJson(String jsonString); |
||||
} |
||||
|
||||
public interface IHelper { |
||||
void onNavigation2CoordinateSystemHelp(); |
||||
} |
||||
} |
@ -0,0 +1,104 @@ |
||||
package com.project.survey.ui.instrument.coordinatesystem; |
||||
|
||||
import android.content.Context; |
||||
|
||||
import androidx.annotation.WorkerThread; |
||||
import androidx.appcompat.app.AppCompatActivity; |
||||
import androidx.fragment.app.Fragment; |
||||
import androidx.lifecycle.Lifecycle; |
||||
import androidx.lifecycle.LiveData; |
||||
import androidx.lifecycle.MutableLiveData; |
||||
|
||||
import com.bingce.coordlib.model.CoordinateSystem; |
||||
import com.bingce.data.cache.CacheHelper; |
||||
import com.bingce.data.cache.CachedObserver; |
||||
import com.bingce.data.database.DBQueryConstant; |
||||
import com.bingce.data.database.KeyValueDb; |
||||
import com.bingce.data.database.ProjectDb; |
||||
import com.bingce.data.surveyor.designdata.kv.KeyValueConstants; |
||||
import com.bingce.data.surveyor.designdata.project.ProjectConstants; |
||||
import com.bingce.data.surveyor.designdata.project.ProjectRecord; |
||||
import com.bingce.utils.IProvider; |
||||
import com.bingce.utils.KVLiveDataIgnoreUserSwitch; |
||||
|
||||
import blankj.utilcode.util.Utils; |
||||
|
||||
public class CachedCurrentCoordinateSystem extends CacheHelper { |
||||
private final KVLiveDataIgnoreUserSwitch currentProjectKV = new KVLiveDataIgnoreUserSwitch(KeyValueConstants.KEY_CURRENT_PROJECT_ID); |
||||
private final IProvider<Context> context; |
||||
//当前项目实例
|
||||
private LiveData<ProjectRecord> projectRecordLiveData = null; |
||||
//当前坐标系实例
|
||||
private final MutableLiveData<CoordinateSystem> currentCoordinateSystemMutableLiveData = new MutableLiveData<>(); |
||||
|
||||
public CachedCurrentCoordinateSystem(AppCompatActivity activity) { |
||||
super(activity.getLifecycle()); |
||||
context = () -> activity; |
||||
addLifeCycle(getLifecycle()); |
||||
} |
||||
|
||||
public CachedCurrentCoordinateSystem(Fragment fragment) { |
||||
super(fragment.getLifecycle()); |
||||
context = fragment::getContext; |
||||
addLifeCycle(getLifecycle()); |
||||
} |
||||
|
||||
protected void addLifeCycle(Lifecycle lifecycle) { |
||||
//1.监听当前坐标系id
|
||||
currentProjectKV |
||||
.observe(this, configRecord -> { |
||||
// if (configRecord == null) {
|
||||
// return;
|
||||
// }
|
||||
// if (projectRecordLiveData != null) {
|
||||
// projectRecordLiveData.removeObservers(this);
|
||||
// }
|
||||
// projectRecordLiveData = ProjectDb.getInstance()
|
||||
// .rawQueryLiveData(DBQueryConstant.findById(ProjectConstants.DB_NAME, configRecord.value));
|
||||
//
|
||||
// projectRecordLiveData.observe(this, projectRecord -> {
|
||||
// CoordinateSystem coordinateSystem = projectRecord == null ? null : projectRecord.coordinateSystem;
|
||||
// currentCoordinateSystemMutableLiveData.setValue(coordinateSystem == null ? CoordinateSystem.newCoordinateSystem(context.value()) : coordinateSystem);
|
||||
// });
|
||||
currentCoordinateSystemMutableLiveData.setValue(CoordinateSystem.newCoordinateSystem(context.value())); |
||||
|
||||
}); |
||||
} |
||||
|
||||
public CoordinateSystem coordinateSystem() { |
||||
CoordinateSystem coordinateRecord = currentCoordinateSystemMutableLiveData.getValue(); |
||||
if (coordinateRecord == null) { |
||||
throw new RuntimeException("coordinate system not ready"); |
||||
} |
||||
return coordinateRecord; |
||||
} |
||||
|
||||
public boolean isDataReady() { |
||||
return currentCoordinateSystemMutableLiveData.getValue() != null; |
||||
} |
||||
|
||||
public void observe(CachedObserver<CoordinateSystem> observer) { |
||||
currentCoordinateSystemMutableLiveData.observe(this, observer); |
||||
} |
||||
|
||||
|
||||
@WorkerThread |
||||
public static CoordinateSystem currentCoordinateSystem() { |
||||
String projectId = KeyValueDb.currentProjectId(); |
||||
ProjectRecord projectRecord = ProjectDb.getInstance() |
||||
.rawQueryData(DBQueryConstant.findById(ProjectConstants.DB_NAME, projectId)); |
||||
return projectRecord == null ? CoordinateSystem.newCoordinateSystem(Utils.getApp()) : projectRecord.coordinateSystem; |
||||
} |
||||
|
||||
@WorkerThread |
||||
public static void saveCurrentCoordinateSystem(CoordinateSystem system) { |
||||
String projectId = KeyValueDb.currentProjectId(); |
||||
ProjectRecord projectRecord = ProjectDb.getInstance() |
||||
.rawQueryData(DBQueryConstant.findById(ProjectConstants.DB_NAME, projectId)); |
||||
if (projectRecord == null) { |
||||
return; |
||||
} |
||||
projectRecord.coordinateSystem = system; |
||||
ProjectDb.getInstance().save(projectRecord); |
||||
} |
||||
} |
@ -0,0 +1,390 @@ |
||||
package com.project.survey.ui.instrument.coordinatesystem.fragment; |
||||
|
||||
import android.app.Activity; |
||||
import android.content.Intent; |
||||
import android.graphics.Color; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.Menu; |
||||
import android.view.MenuInflater; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.fragment.app.Fragment; |
||||
import androidx.fragment.app.FragmentActivity; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.fragment.app.FragmentPagerAdapter; |
||||
import androidx.viewpager.widget.ViewPager; |
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog; |
||||
import com.bingce.coordlib.model.CoordinateSystem; |
||||
import com.bingce.coordlib.util.CoordinateSystemUtil; |
||||
import com.bingce.data.cache.AbstractCachedObserver; |
||||
import com.bingce.data.database.CoordinateSystemDb; |
||||
import com.bingce.data.database.DBQueryConstant; |
||||
import com.bingce.data.surveyor.designdata.coordinate.CoordinateSystemConstants; |
||||
import com.bingce.data.surveyor.designdata.coordinate.CoordinateSystemRecord; |
||||
import com.bingce.device.Device; |
||||
import com.bingce.device.ui.coordinatesystem.event.UpdateCoordinateSystemEvent; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.AbstractCoordinateSystemContainerFragment; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.BaseCorrectionFragment; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.CoordinatorFragmentInterface; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.DatumTransformFragment; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.ElevationFittingFragment; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.EllipsoidFragment; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.GridTransformFragment; |
||||
import com.bingce.device.ui.coordinatesystem.fragment.ProjectionFragment; |
||||
import com.bingce.device.ui.utils.CoordSysShareUtil; |
||||
import com.bingce.dialog.DialogUtils; |
||||
import com.bingce.event.SingleMessageEvent; |
||||
import com.bingce.surveyorBase.R; |
||||
import com.bingce.ui.coordinatesystem.PresetCoordinateSystemV2Activity; |
||||
import com.bingce.utils.SoftKeyUtils; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
import com.bingce.utils.ValidateUtil; |
||||
import com.flyco.tablayout.SlidingTabLayout; |
||||
import com.project.survey.ui.instrument.coordinatesystem.CachedCurrentCoordinateSystem; |
||||
import com.project.survey.ui.instrument.mobilestationmode.base.RtkPointCorrectActivity; |
||||
import com.rengwuxian.materialedittext.MaterialEditText; |
||||
|
||||
import org.greenrobot.eventbus.EventBus; |
||||
import org.greenrobot.eventbus.Subscribe; |
||||
import org.greenrobot.eventbus.ThreadMode; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import blankj.utilcode.util.StringUtils; |
||||
import blankj.utilcode.util.ToastUtils; |
||||
|
||||
public class CoordinateSystemContainerFragment extends AbstractCoordinateSystemContainerFragment { |
||||
protected final CachedCurrentCoordinateSystem cachedCoordinateSystem = new CachedCurrentCoordinateSystem(this); |
||||
private MaterialEditText met_name; |
||||
private ViewPager mViewPager; |
||||
private SlidingTabLayout mSlidingTabLayout; |
||||
private boolean isReturnSys = false; |
||||
private boolean isReadOnly = false; |
||||
private boolean skip2Proj = false; |
||||
private final CoordSysShareUtil.Export export = new CoordSysShareUtil.Export(); |
||||
private final CoordSysShareUtil.Import anImport = new CoordSysShareUtil.Import(); |
||||
|
||||
@Override |
||||
public void onCreate(@Nullable Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
EventBus.getDefault().register(this); |
||||
} |
||||
|
||||
protected View contentView(LayoutInflater inflater, @Nullable ViewGroup container) { |
||||
return inflater.inflate(R.layout.fragment_coordinate_system, container, false); |
||||
} |
||||
|
||||
@Override |
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = contentView(inflater, container); |
||||
met_name = view.findViewById(R.id.fragment_coordinate_system_name); |
||||
mViewPager = view.findViewById(R.id.fragment_coordinate_system_viewpager); |
||||
mSlidingTabLayout = view.findViewById(R.id.fragment_coordinate_system_viewpager_tab); |
||||
return view; |
||||
} |
||||
|
||||
@Override |
||||
protected void onViewReady(CoordinatorFragmentInterface.ICoordinatorContainerFragment container, CoordinateSystem coordinateSystem) { |
||||
setHasOptionsMenu(true); |
||||
initMaterialEditTextColor(); |
||||
met_name.setText(coordinateSystem.getName()); |
||||
|
||||
String[] mTitles = new String[]{getString(R.string.ellipsoid), getString(R.string.projection) |
||||
, getString(R.string.datum_transform), getString(R.string.plane_transform) |
||||
, getString(R.string.elevation_fitting), getString(R.string.base_correction_parameters)}; |
||||
|
||||
if (getArguments() != null) { |
||||
isReadOnly = getArguments().getBoolean(KEY_READ_ONLY, false); |
||||
//如果是只读,需要隐藏底部button,将name设置为只读
|
||||
if (isReadOnly && getView() != null) { |
||||
View bottomLayout = getView().findViewById(R.id.bottom_layout); |
||||
if (bottomLayout != null) { |
||||
bottomLayout.setVisibility(View.INVISIBLE); |
||||
} |
||||
met_name.setEnabled(false); |
||||
} |
||||
} |
||||
ArrayList<Fragment> mFragments = new ArrayList<>(); |
||||
mFragments.add(EllipsoidFragment.newInstance(getArguments())); |
||||
mFragments.add(ProjectionFragment.newInstance(getArguments())); |
||||
mFragments.add(DatumTransformFragment.newInstance(getArguments())); |
||||
mFragments.add(GridTransformFragment.newInstance(getArguments())); |
||||
mFragments.add(ElevationFittingFragment.newInstance(getArguments())); |
||||
mFragments.add(BaseCorrectionFragment.newInstance(getArguments())); |
||||
|
||||
for (Fragment fragment : mFragments) { |
||||
if (fragment instanceof CoordinatorFragmentInterface.ICoordinatorAttributeFragment) { |
||||
container.register((CoordinatorFragmentInterface.ICoordinatorAttributeFragment) fragment); |
||||
} |
||||
} |
||||
|
||||
mViewPager.setAdapter(new MyPagerAdapter(getChildFragmentManager(), mTitles, mFragments)); |
||||
mViewPager.setOffscreenPageLimit(10); |
||||
|
||||
mSlidingTabLayout.setViewPager(mViewPager); |
||||
|
||||
mViewPager.setElevation(0); |
||||
mSlidingTabLayout.setElevation(10); |
||||
|
||||
if (getArguments() != null) { |
||||
if (getArguments().containsKey("tabColor") && mSlidingTabLayout != null) |
||||
mSlidingTabLayout.setBackgroundColor(getArguments().getInt("tabColor")); |
||||
isReturnSys = getArguments().getBoolean(KEY_RETURN_SYS, false); |
||||
skip2Proj = getArguments().getBoolean(KEY_SKIP2PROJ, false); |
||||
if (skip2Proj) { |
||||
mSlidingTabLayout.setCurrentTab(1, true); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void observeCurrentCoordinateSystem(AbstractCachedObserver<CoordinateSystem> observer) { |
||||
cachedCoordinateSystem.observe(observer); |
||||
} |
||||
|
||||
public void onQuitClicked() { |
||||
getActivity().finish(); |
||||
} |
||||
|
||||
public void onAcceptClicked() { |
||||
SoftKeyUtils.hideSoftKey(); |
||||
save(() -> { |
||||
ToastUtils.showShort(R.string.save_success); |
||||
getActivity().finish(); |
||||
}); |
||||
} |
||||
|
||||
public void onCalcClicked() { |
||||
mSlidingTabLayout.setCurrentTab(1, true); |
||||
new MaterialDialog.Builder(requireContext()) |
||||
.title(R.string.hint) |
||||
.content(R.string.seven_or_four_para_hint) |
||||
.positiveText(R.string.go_to_config) |
||||
.negativeText(R.string.configured) |
||||
.onNegative((dialog, which) -> { |
||||
save(() -> { |
||||
Intent intent = new Intent(requireContext(), RtkPointCorrectActivity.class); |
||||
intent.putExtra("from", 1); |
||||
startActivity(intent); |
||||
// EventBus.getDefault().post(new SingleMessageEvent("coordinate_system_parameter_calc"));
|
||||
}); |
||||
}) |
||||
.show(); |
||||
} |
||||
|
||||
private void save(Runnable success) { |
||||
String name = ValidateUtil.filterSpecialChar(met_name.getText().toString().trim()); |
||||
if (StringUtils.isEmpty(name)) { |
||||
return; |
||||
} |
||||
setCoordinateSystemName(name); |
||||
checkFragmentsAndSyncData2Object(new CoordinatorFragmentInterface.ISaveCallback() { |
||||
@Override |
||||
public void onSuccess(CoordinateSystem coordinateSystem) { |
||||
if (isReturnSys) { |
||||
Intent intent = new Intent(); |
||||
intent.putExtra(KEY_TXT, CoordinateSystemUtil.exportCoordSysString(coordinateSystem)); |
||||
getActivity().setResult(Activity.RESULT_OK, intent); |
||||
success.run(); |
||||
} else { |
||||
ThreadPoolUtil.execute(() -> { |
||||
//搜索当前坐标系
|
||||
// KeyValueRecord currentProjectConfig = KeyValueDb.getInstance().findData(KeyValueConstants.KEY_CURRENT_PROJECT_ID);
|
||||
// if (currentProjectConfig == null) {
|
||||
// BingCeErrorCode.toast(BingCeErrorCode.NO_CURRENT_PROJECT);
|
||||
// return;
|
||||
// }
|
||||
// ProjectRecord currentProjectRecord = ProjectDb.getInstance()
|
||||
// .rawQueryData(DBQueryConstant.findById(ProjectConstants.DB_NAME, currentProjectConfig.value));
|
||||
// if (currentProjectRecord == null) {
|
||||
// BingCeErrorCode.toast(BingCeErrorCode.NO_FOUND_PROJECT_BY_ID);
|
||||
// return;
|
||||
// }
|
||||
// currentProjectRecord.coordinateSystem = coordinateSystem;
|
||||
// ProjectDb.getInstance().save(currentProjectRecord);
|
||||
|
||||
// TODO: 2024/8/15 存坐标系
|
||||
//切换线路
|
||||
ThreadPoolUtil.executeInMain(success); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onFailure(int index, CoordinatorFragmentInterface.ICoordinatorAttributeFragment listener) { |
||||
mSlidingTabLayout.setCurrentTab(index, true); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { |
||||
super.onCreateOptionsMenu(menu, inflater); |
||||
if (getArguments() != null) { |
||||
isReadOnly = getArguments().getBoolean(KEY_READ_ONLY, false); |
||||
} |
||||
if (!isReadOnly && !isReturnSys) {//如果只读,就不显示右上角菜单
|
||||
inflater.inflate(R.menu.menu_fragment_coordinate_system, menu); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(MenuItem item) { |
||||
int itemId = item.getItemId(); |
||||
if (itemId == R.id.menu_fragment_coordinate_system_library) { |
||||
FragmentActivity activity = getActivity(); |
||||
if (activity != null) { |
||||
PresetCoordinateSystemV2Activity.selectCoordinateSystem(activity, coordinateSystem -> { |
||||
if (coordinateSystem != null) { |
||||
met_name.setText(coordinateSystem.getName()); |
||||
onCoordinateSystemChanged(coordinateSystem); |
||||
} |
||||
}); |
||||
} |
||||
} else if (itemId == R.id.menu_fragment_coordinate_system_save) { |
||||
//先收集界面内数据
|
||||
String name = ValidateUtil.filterSpecialChar(met_name.getText().toString().trim()); |
||||
if (StringUtils.isEmpty(name)) { |
||||
ToastUtils.showShort(R.string.coordinate_system_name_cannot_be_empty); |
||||
return true; |
||||
} |
||||
setCoordinateSystemName(name); |
||||
checkFragmentsAndSyncData2Object(new CoordinatorFragmentInterface.ISaveCallback() { |
||||
@Override |
||||
public void onSuccess(CoordinateSystem coordinateSystem) { |
||||
ThreadPoolUtil.execute(() -> { |
||||
List<CoordinateSystemRecord> records = CoordinateSystemDb.getInstance() |
||||
.rawQueryListData(DBQueryConstant.findAll(CoordinateSystemConstants.DB_NAME)); |
||||
//检测是否有重名
|
||||
List<CoordinateSystemRecord> sameNameList = new ArrayList<>(); |
||||
if (records != null) { |
||||
for (CoordinateSystemRecord record : records) { |
||||
if (record == null) { |
||||
continue; |
||||
} |
||||
if (record.coordinateSystem.getName().equals(coordinateSystem.getName())) { |
||||
sameNameList.add(record); |
||||
} |
||||
} |
||||
} |
||||
if (sameNameList.isEmpty()) { |
||||
CoordinateSystemRecord record = new CoordinateSystemRecord(coordinateSystem, new Date()); |
||||
CoordinateSystemDb.getInstance().save(record); |
||||
ToastUtils.showShort(R.string.save_success); |
||||
} else { |
||||
ThreadPoolUtil.executeInMain(() -> { |
||||
DialogUtils.tips(getContext(), |
||||
getString(R.string.warning), |
||||
getString(R.string.already_has_same_name_coordinate_system_r_u_sure_overwrite), |
||||
() -> { |
||||
//覆盖存储
|
||||
ThreadPoolUtil.execute(() -> { |
||||
for (CoordinateSystemRecord record : sameNameList) { |
||||
record.coordinateSystem = coordinateSystem; |
||||
} |
||||
CoordinateSystemDb.getInstance().save(sameNameList); |
||||
ToastUtils.showShort(R.string.save_success); |
||||
}); |
||||
}, |
||||
null); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void onFailure(int index, CoordinatorFragmentInterface.ICoordinatorAttributeFragment listener) { |
||||
mSlidingTabLayout.setCurrentTab(index, true); |
||||
} |
||||
}); |
||||
} else if (itemId == R.id.menu_fragment_coordinate_system_share) { |
||||
showShareParametersDialog(); |
||||
} else if (itemId == R.id.menu_fragment_coordinate_system_import) { |
||||
showImportParametersDialog(); |
||||
} |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
|
||||
private void showShareParametersDialog() { |
||||
export.showSharedDialog(getContext(), currentCoordinateSystem()); |
||||
} |
||||
|
||||
private void showImportParametersDialog() { |
||||
anImport.showImportDialog(getContext(), system -> { |
||||
met_name.setText(system.getName()); |
||||
onCoordinateSystemChanged(system); |
||||
}); |
||||
} |
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN) |
||||
public void onMessageEvent(UpdateCoordinateSystemEvent event) { |
||||
onCoordinateSystemChanged(null); |
||||
} |
||||
|
||||
@Override |
||||
public void onDestroy() { |
||||
super.onDestroy(); |
||||
EventBus.getDefault().unregister(this); |
||||
} |
||||
|
||||
private void initMaterialEditTextColor() { |
||||
if (Device.getInstance().isThemeDark) { |
||||
met_name.setMetTextColor(Color.WHITE); |
||||
|
||||
met_name.setPrimaryColor(Color.LTGRAY); |
||||
|
||||
met_name.setFocusFraction(1.0f); |
||||
|
||||
met_name.setMetHintTextColor(Color.LTGRAY); |
||||
|
||||
met_name.setUnderlineColor(Color.LTGRAY); |
||||
} |
||||
} |
||||
|
||||
public static class MyPagerAdapter extends FragmentPagerAdapter { |
||||
private final String[] mTitle; |
||||
private final List<Fragment> mFragments; |
||||
|
||||
public MyPagerAdapter(@NonNull FragmentManager fm, String[] mTitle, List<Fragment> lists) { |
||||
super(fm); |
||||
this.mTitle = mTitle; |
||||
this.mFragments = lists; |
||||
} |
||||
|
||||
@NonNull |
||||
@Override |
||||
public Fragment getItem(int position) { |
||||
return mFragments.get(position); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public CharSequence getPageTitle(int position) { |
||||
return mTitle[position]; |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return mFragments != null && mFragments.size() == 0 ? 0 : mFragments.size(); |
||||
} |
||||
} |
||||
|
||||
public Fragment getViewPagerFragment(int viewId, int index) { |
||||
String tag = "android:switcher:" + viewId + ":" + index; |
||||
return getChildFragmentManager().findFragmentByTag(tag); |
||||
} |
||||
|
||||
public static Fragment newInstance(Bundle args) { |
||||
CoordinateSystemContainerFragment fragment = new CoordinateSystemContainerFragment(); |
||||
fragment.setArguments(args); |
||||
return fragment; |
||||
} |
||||
} |
@ -0,0 +1,383 @@ |
||||
package com.project.survey.ui.instrument.mobilestationmode.base; |
||||
|
||||
import android.graphics.Color; |
||||
import android.view.View; |
||||
import android.widget.Button; |
||||
import android.widget.CheckBox; |
||||
import android.widget.EditText; |
||||
|
||||
import androidx.annotation.WorkerThread; |
||||
|
||||
import com.bingce.coordlib.model.Blh; |
||||
import com.bingce.coordlib.model.BlhCoordinatePair; |
||||
import com.bingce.coordlib.model.Coordinate; |
||||
import com.bingce.coordlib.model.CoordinateSystem; |
||||
import com.bingce.device.Device; |
||||
import com.bingce.device.ui.AbstractSurveyActivity; |
||||
import com.bingce.utils.ColorUtil; |
||||
import com.bingce.utils.IOnSingleGetCallback; |
||||
import com.bingce.utils.SoftKeyUtils; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
import com.bingce.utils.Util; |
||||
import com.daimajia.numberprogressbar.NumberProgressBar; |
||||
import com.rengwuxian.materialedittext.MaterialEditText; |
||||
|
||||
import blankj.utilcode.util.ToastUtils; |
||||
import device.ui.Rid; |
||||
import device.ui.Rlayout; |
||||
import device.ui.Rstring; |
||||
|
||||
public abstract class AbstractRtkMatchingPointsActivity extends AbstractSurveyActivity { |
||||
private EditText et_0; |
||||
private MaterialEditText met_b, met_l, met_h, met_name, met_x, met_y, met_z; |
||||
private Button mBtnCollect, mBtnSave; |
||||
private CheckBox mCheckUseH, mCheckUseV; |
||||
private CoordinateSystem coordinateSystem; |
||||
private int mTimes = -1, position = -1; |
||||
private double mSumB, mSumL, mSumH; |
||||
private View mBtnOpen1, mBtnOpen2; |
||||
private double b, l, h, x, y, z; |
||||
private NumberProgressBar progressBar; |
||||
// protected final CachedCurrentCoordinateSystem cachedCoordinateSystem = new CachedCurrentCoordinateSystem(this);
|
||||
|
||||
@Override |
||||
protected int getLayoutId() { |
||||
return Rlayout.activity_rtk_matching_points(); |
||||
} |
||||
|
||||
@Override |
||||
protected void initView() { |
||||
position = getIntent().getIntExtra("position", -1); |
||||
et_0 = findViewById(Rid.activity_rtk_matching_points_et_0()); |
||||
met_b = findViewById(Rid.activity_rtk_matching_points_met_b()); |
||||
met_l = findViewById(Rid.activity_rtk_matching_points_met_l()); |
||||
met_h = findViewById(Rid.activity_rtk_matching_points_met_h()); |
||||
met_name = findViewById(Rid.activity_rtk_matching_points_met_name()); |
||||
met_x = findViewById(Rid.activity_rtk_matching_points_met_x()); |
||||
met_y = findViewById(Rid.activity_rtk_matching_points_met_y()); |
||||
met_z = findViewById(Rid.activity_rtk_matching_points_met_z()); |
||||
mBtnOpen1 = findViewById(Rid.activity_rtk_matching_points_btn_open1()); |
||||
mBtnOpen2 = findViewById(Rid.activity_rtk_matching_points_btn_open2()); |
||||
mBtnCollect = findViewById(Rid.activity_rtk_matching_points_btn_collect()); |
||||
mBtnSave = findViewById(Rid.activity_rtk_matching_points_btn_save()); |
||||
mCheckUseH = findViewById(Rid.activity_rtk_matching_points_cb_use_horizontal()); |
||||
mCheckUseV = findViewById(Rid.activity_rtk_matching_points_cb_use_vertical()); |
||||
progressBar = findViewById(Rid.activity_rtk_matching_points_progressbar()); |
||||
progressBar.setReachedBarColor(ColorUtil.getColorPrimary(this)); |
||||
|
||||
mBtnCollect.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
// et_0.requestFocus();//作用:输入框不聚焦,防止实测坐标后页面自动滑动到顶部,同样避免RTK继续后输入框没有失效焦点,导致再输入内容输入法自动隐藏的问题
|
||||
// CommonUtils.hideSoftInput();
|
||||
SoftKeyUtils.hideSoftKey(); |
||||
|
||||
Device.getInstance().isRtkRunning = true; |
||||
mTimes = 0; |
||||
mSumB = 0; |
||||
mSumL = 0; |
||||
mSumH = 0; |
||||
met_b.setText(""); |
||||
met_l.setText(""); |
||||
met_h.setText(""); |
||||
progressBar.setProgress(0); |
||||
} |
||||
}); |
||||
mBtnSave.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
// et_0.requestFocus();//作用:输入框不聚焦,防止实测坐标后页面自动滑动到顶部
|
||||
// CommonUtils.hideSoftInput();
|
||||
SoftKeyUtils.hideSoftKey(); |
||||
if (checkActionEnable()) { |
||||
x = Double.parseDouble(met_x.getText().toString()); |
||||
y = Double.parseDouble(met_y.getText().toString()); |
||||
z = Double.parseDouble(met_z.getText().toString()); |
||||
b = Math.toDegrees(Util.dmsStringToRadian(met_b.getText().toString(), false)); |
||||
l = Math.toDegrees(Util.dmsStringToRadian(met_l.getText().toString(), false)); |
||||
h = Double.parseDouble(met_h.getText().toString()); |
||||
|
||||
if (position >= 0 && position < coordinateSystem.getPairs().size()) { |
||||
coordinateSystem.getPairs().set(position, new BlhCoordinatePair(met_name.getText().toString(), new Blh(b, l, h), new Coordinate(x, y, z), mCheckUseH.isChecked(), mCheckUseV.isChecked())); |
||||
} else { |
||||
coordinateSystem.getPairs().add(new BlhCoordinatePair(met_name.getText().toString(), new Blh(b, l, h), new Coordinate(x, y, z), mCheckUseH.isChecked(), mCheckUseV.isChecked())); |
||||
} |
||||
ThreadPoolUtil.execute(() -> { |
||||
// ProjectDb.getInstance().updateCurrentCoordinator(coordinateSystem);
|
||||
save(coordinateSystem); |
||||
runOnUiThread(() -> { |
||||
setResult(RESULT_OK); |
||||
finish(); |
||||
}); |
||||
}); |
||||
} |
||||
} |
||||
}); |
||||
mBtnOpen1.setOnClickListener(view -> { |
||||
et_0.requestFocus(); |
||||
SoftKeyUtils.hideSoftKey(); |
||||
selectBLH(); |
||||
// CommonUtils.hideSoftInput();
|
||||
// new MaterialDialog.Builder(RtkMatchingPointsActivity.this)
|
||||
// .title(Rstring.data_source)
|
||||
// .items(new String[]{getString(Rstring.point_survey_point_library)})
|
||||
// .itemsCallback((dialog, itemView, which, text) -> {
|
||||
// switch (which) {
|
||||
// case 0:
|
||||
// CoordinatePointsLibraryActivity.pickPoint(this, (name, code, x, y, z, b, l, h) -> {
|
||||
// onPicked(b, l, h);
|
||||
// });
|
||||
// break;
|
||||
// }
|
||||
// }).show();
|
||||
}); |
||||
mBtnOpen2.setOnClickListener(view -> { |
||||
et_0.requestFocus(); |
||||
SoftKeyUtils.hideSoftKey(); |
||||
selectXYZ(); |
||||
// CommonUtils.hideSoftInput();
|
||||
// new MaterialDialog.Builder(RtkMatchingPointsActivity.this)
|
||||
// .title(Rstring.data_source)
|
||||
// .items(new String[]{getString(Rstring.road_control_point), getString(Rstring.global_control_point), getString(Rstring.point_survey_point_library), getString(Rstring.staking_point_library)})
|
||||
// .itemsCallback((dialog, itemView, which, text) -> {
|
||||
// switch (which) {
|
||||
// case 0:
|
||||
// ControlPointsNewActivity.pickPoint(this, false, (name, code, x, y, z, remarks) -> {
|
||||
// onPicked(name, x, y, z);
|
||||
// });
|
||||
// break;
|
||||
// case 1:
|
||||
// ControlPointsNewActivity.pickPoint(this, true, (name, code, x, y, z, remarks) -> {
|
||||
// onPicked(name, x, y, z);
|
||||
// });
|
||||
// break;
|
||||
// case 2:
|
||||
// CoordinatePointsLibraryActivity.pickPoint(this, (name, code, x, y, z, b, l, h) -> {
|
||||
// onPicked(name, x, y, z);
|
||||
// });
|
||||
// break;
|
||||
// case 3:
|
||||
// StakingJobActivity.pickPoint(this, (name, x, y, z) -> {
|
||||
// onPicked(name, x, y, z);
|
||||
// });
|
||||
// break;
|
||||
// }
|
||||
// }).show();
|
||||
}); |
||||
initMaterialEditTextColor(); |
||||
|
||||
// cachedCoordinateSystem.observe(new AbstractCachedObserver<CoordinateSystem>() {
|
||||
// @Override
|
||||
// public void onChanged(boolean isFirstTimeDataChanged, CoordinateSystem coordinateSystem) {
|
||||
// if (isFirstTimeDataChanged) {
|
||||
// init(coordinateSystem);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
loadCurrentCoordinateSystem(this::init); |
||||
} |
||||
|
||||
protected void init(CoordinateSystem system) { |
||||
coordinateSystem = system; |
||||
if (position >= 0 && position < coordinateSystem.getPairs().size()) { |
||||
b = coordinateSystem.getPairs().get(position).getBlh().getLatitude(); |
||||
l = coordinateSystem.getPairs().get(position).getBlh().getLongitude(); |
||||
h = coordinateSystem.getPairs().get(position).getBlh().getAltitude(); |
||||
x = coordinateSystem.getPairs().get(position).getCoordinate().getX(); |
||||
y = coordinateSystem.getPairs().get(position).getCoordinate().getY(); |
||||
z = coordinateSystem.getPairs().get(position).getCoordinate().getZ(); |
||||
met_b.setText(Util.radianToDmsDoubleString(Math.toRadians(b), 6, false)); |
||||
met_l.setText(Util.radianToDmsDoubleString(Math.toRadians(l), 6, false)); |
||||
met_h.setText(Util.formatDouble2StringDotAuto(h)); |
||||
met_name.setText(coordinateSystem.getPairs().get(position).getName()); |
||||
met_x.setText(Util.formatDouble2StringDotAuto(x)); |
||||
met_y.setText(Util.formatDouble2StringDotAuto(y)); |
||||
met_z.setText(Util.formatDouble2StringDotAuto(z)); |
||||
mCheckUseH.setChecked(coordinateSystem.getPairs().get(position).isUseH()); |
||||
mCheckUseV.setChecked(coordinateSystem.getPairs().get(position).isUseV()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void initData() { |
||||
|
||||
} |
||||
|
||||
protected final void onPicked(double b, double l, double h) { |
||||
met_b.setText(Util.radianToDmsDoubleString(Math.toRadians(b), 6, false)); |
||||
met_l.setText(Util.radianToDmsDoubleString(Math.toRadians(l), 6, false)); |
||||
met_h.setText(Util.formatDouble2StringDotAuto(h)); |
||||
ToastUtils.showShort(Rstring.open_point_successful()); |
||||
} |
||||
|
||||
final protected void onPicked(String name, double x, double y, double z) { |
||||
if (name != null) met_name.setText(name); |
||||
met_x.setText(Util.formatDouble2StringDotAuto(x)); |
||||
met_y.setText(Util.formatDouble2StringDotAuto(y)); |
||||
met_z.setText(Util.formatDouble2StringDotAuto(z)); |
||||
ToastUtils.showShort(Rstring.open_point_successful()); |
||||
} |
||||
|
||||
private boolean checkActionEnable() { |
||||
if (!mCheckUseH.isChecked() && !mCheckUseV.isChecked()) { |
||||
ToastUtils.showShort(Rstring.use_horizontal_or_use_vertical_must_check_at_least_one()); |
||||
return false; |
||||
} |
||||
boolean check_empty_b, check_empty_l, check_empty_h, check_empty_x, check_empty_y, check_empty_z; |
||||
String b_text = met_b.getText().toString().trim(); |
||||
String l_text = met_l.getText().toString().trim(); |
||||
String h_text = met_h.getText().toString().trim(); |
||||
String x_text = met_x.getText().toString().trim(); |
||||
String y_text = met_y.getText().toString().trim(); |
||||
String z_text = met_z.getText().toString().trim(); |
||||
|
||||
check_empty_b = !"".equals(b_text) && !"-".equals(b_text) && !"+".equals(b_text) && !".".equals(b_text) && !"-.".equals(b_text) && !"+.".equals(b_text); |
||||
if (check_empty_b) { |
||||
try { |
||||
double b = Math.toDegrees(Util.dmsStringToRadian(met_b.getText().toString(), false)); |
||||
if (b < -90 || b > 90) { |
||||
met_b.setError(getString(Rstring.latitude_invalid())); |
||||
check_empty_b = false; |
||||
} else { |
||||
met_b.setError(null); |
||||
check_empty_b = true; |
||||
} |
||||
} catch (NumberFormatException ex) { |
||||
check_empty_b = false; |
||||
met_b.setError(getString(Rstring.latitude_invalid())); |
||||
} |
||||
} else { |
||||
met_b.setError(getString(Rstring.illegal_value())); |
||||
} |
||||
check_empty_l = !"".equals(l_text) && !"-".equals(l_text) && !"+".equals(l_text) && !".".equals(l_text) && !"-.".equals(l_text) && !"+.".equals(l_text); |
||||
if (check_empty_l) { |
||||
try { |
||||
double l = Math.toDegrees(Util.dmsStringToRadian(met_l.getText().toString(), false)); |
||||
if (l < -180 || l > 180) { |
||||
met_l.setError(getString(Rstring.longitude_invalid())); |
||||
check_empty_l = false; |
||||
} else { |
||||
met_l.setError(null); |
||||
check_empty_l = true; |
||||
} |
||||
} catch (NumberFormatException ex) { |
||||
met_l.setError(getString(Rstring.longitude_invalid())); |
||||
check_empty_l = false; |
||||
} |
||||
} else { |
||||
met_l.setError(getString(Rstring.illegal_value())); |
||||
} |
||||
|
||||
check_empty_h = !"".equals(h_text) && !"-".equals(h_text) && !"+".equals(h_text) && !".".equals(h_text) && !"-.".equals(h_text) && !"+.".equals(h_text); |
||||
if (check_empty_h) { |
||||
met_h.setError(null); |
||||
} else { |
||||
met_h.setError(getString(Rstring.illegal_value())); |
||||
} |
||||
check_empty_x = !"".equals(x_text) && !"-".equals(x_text) && !"+".equals(x_text) && !".".equals(x_text) && !"-.".equals(x_text) && !"+.".equals(x_text); |
||||
if (check_empty_x) { |
||||
met_x.setError(null); |
||||
} else { |
||||
met_x.setError(getString(Rstring.input_illegal())); |
||||
} |
||||
check_empty_y = !"".equals(y_text) && !"-".equals(y_text) && !"+".equals(y_text) && !".".equals(y_text) && !"-.".equals(y_text) && !"+.".equals(y_text); |
||||
if (check_empty_y) { |
||||
met_y.setError(null); |
||||
} else { |
||||
met_y.setError(getString(Rstring.input_illegal())); |
||||
} |
||||
check_empty_z = !"".equals(z_text) && !"-".equals(z_text) && !"+".equals(z_text) && !".".equals(z_text) && !"-.".equals(z_text) && !"+.".equals(z_text); |
||||
if (check_empty_z) { |
||||
met_z.setError(null); |
||||
} else { |
||||
met_z.setError(getString(Rstring.input_illegal())); |
||||
} |
||||
|
||||
return check_empty_b && check_empty_l && check_empty_h && check_empty_x && check_empty_y && check_empty_z; |
||||
} |
||||
|
||||
private void initMaterialEditTextColor() { |
||||
if (/*((App) Utils.getApp()).*/isThemeDark()) { |
||||
met_b.setMetTextColor(Color.WHITE); |
||||
met_l.setMetTextColor(Color.WHITE); |
||||
met_h.setMetTextColor(Color.WHITE); |
||||
met_name.setMetTextColor(Color.WHITE); |
||||
met_x.setMetTextColor(Color.WHITE); |
||||
met_y.setMetTextColor(Color.WHITE); |
||||
met_z.setMetTextColor(Color.WHITE); |
||||
|
||||
met_b.setPrimaryColor(Color.LTGRAY); |
||||
met_l.setPrimaryColor(Color.LTGRAY); |
||||
met_h.setPrimaryColor(Color.LTGRAY); |
||||
met_name.setPrimaryColor(Color.LTGRAY); |
||||
met_x.setPrimaryColor(Color.LTGRAY); |
||||
met_y.setPrimaryColor(Color.LTGRAY); |
||||
met_z.setPrimaryColor(Color.LTGRAY); |
||||
|
||||
met_b.setFocusFraction(1.0f); |
||||
met_l.setFocusFraction(1.0f); |
||||
met_h.setFocusFraction(1.0f); |
||||
met_name.setFocusFraction(1.0f); |
||||
met_x.setFocusFraction(1.0f); |
||||
met_y.setFocusFraction(1.0f); |
||||
met_z.setFocusFraction(1.0f); |
||||
|
||||
met_b.setMetHintTextColor(Color.GRAY); |
||||
met_l.setMetHintTextColor(Color.GRAY); |
||||
met_h.setMetHintTextColor(Color.GRAY); |
||||
met_name.setMetHintTextColor(Color.GRAY); |
||||
met_x.setMetHintTextColor(Color.GRAY); |
||||
met_y.setMetHintTextColor(Color.GRAY); |
||||
met_z.setMetHintTextColor(Color.GRAY); |
||||
|
||||
met_b.setUnderlineColor(Color.GRAY); |
||||
met_l.setUnderlineColor(Color.GRAY); |
||||
met_h.setUnderlineColor(Color.GRAY); |
||||
met_name.setUnderlineColor(Color.GRAY); |
||||
met_x.setUnderlineColor(Color.GRAY); |
||||
met_y.setUnderlineColor(Color.GRAY); |
||||
met_z.setUnderlineColor(Color.GRAY); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 处理仪器传回的数据 |
||||
*/ |
||||
public void dealReceivedBLH(Blh blh) { |
||||
if (mTimes >= 0 && mTimes < 10) { |
||||
mSumB += blh.getLatitude(); |
||||
mSumL += blh.getLongitude(); |
||||
mSumH += blh.getAltitude(); |
||||
mTimes++; |
||||
progressBar.setProgress(mTimes); |
||||
if (mTimes == 10) { |
||||
b = mSumB / mTimes; |
||||
l = mSumL / mTimes; |
||||
h = mSumH / mTimes; |
||||
met_b.setText(Util.radianToDmsDoubleString(Math.toRadians(b), 6, false)); |
||||
met_l.setText(Util.radianToDmsDoubleString(Math.toRadians(l), 6, false)); |
||||
met_h.setText(Util.formatDouble2StringDotAuto(h)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void updateRtkPosition(boolean isTiltValid, Blh blh, Blh originalBlh, Coordinate coordinate) { |
||||
if (Device.getInstance().isRtkRunning) { |
||||
dealReceivedBLH(blh); |
||||
} |
||||
} |
||||
|
||||
|
||||
///////////////////////
|
||||
protected abstract void selectBLH(); |
||||
|
||||
protected abstract void selectXYZ(); |
||||
|
||||
protected abstract boolean isThemeDark(); |
||||
|
||||
@WorkerThread |
||||
protected abstract void save(CoordinateSystem coordinateSystem); |
||||
|
||||
protected abstract void loadCurrentCoordinateSystem(IOnSingleGetCallback<CoordinateSystem> callback); |
||||
} |
@ -0,0 +1,654 @@ |
||||
package com.project.survey.ui.instrument.mobilestationmode.base; |
||||
|
||||
import android.annotation.SuppressLint; |
||||
import android.content.Context; |
||||
import android.os.Bundle; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.widget.AdapterView; |
||||
import android.widget.ArrayAdapter; |
||||
import android.widget.Button; |
||||
import android.widget.Spinner; |
||||
|
||||
import androidx.annotation.WorkerThread; |
||||
import androidx.appcompat.widget.Toolbar; |
||||
import androidx.core.content.ContextCompat; |
||||
import androidx.recyclerview.widget.LinearLayoutManager; |
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
import com.afollestad.materialdialogs.DialogAction; |
||||
import com.afollestad.materialdialogs.MaterialDialog; |
||||
import com.bingce.coordlib.enums.DatumEnum; |
||||
import com.bingce.coordlib.enums.GridEnum; |
||||
import com.bingce.coordlib.enums.HFittingEnum; |
||||
import com.bingce.coordlib.model.Blh; |
||||
import com.bingce.coordlib.model.BlhCoordinatePair; |
||||
import com.bingce.coordlib.model.Coordinate; |
||||
import com.bingce.coordlib.model.CoordinateSystem; |
||||
import com.bingce.coordlib.model.FourParaResult; |
||||
import com.bingce.coordlib.model.HFitParaResult; |
||||
import com.bingce.coordlib.model.PlaneTgoParaResult; |
||||
import com.bingce.coordlib.model.SevenParaResult; |
||||
import com.bingce.coordlib.proj4j.InvalidValueException; |
||||
import com.bingce.coordlib.proj4j.ProjectionException; |
||||
import com.bingce.coordlib.util.CoorConverter; |
||||
import com.bingce.device.ui.DividerItemDecoration; |
||||
import com.bingce.device.ui.adapter.AbstractMatchingPointRecyclerViewAdapter; |
||||
import com.bingce.device.ui.coordinatesystem.event.UpdateCoordinateSystemEvent; |
||||
import com.bingce.utils.IOnSingleGetCallback; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
import com.bingce.utils.Util; |
||||
|
||||
import org.greenrobot.eventbus.EventBus; |
||||
import org.polaric.colorful.ColorfulActivity; |
||||
|
||||
import blankj.utilcode.util.AppUtils; |
||||
import blankj.utilcode.util.ToastUtils; |
||||
import device.ui.Rdrawable; |
||||
import device.ui.Rid; |
||||
import device.ui.Rlayout; |
||||
import device.ui.Rstring; |
||||
|
||||
public abstract class AbstractRtkPointCorrectActivity extends ColorfulActivity { |
||||
Toolbar mToolbar; |
||||
Spinner mTransMethodSpinner; |
||||
Spinner mFitMethodSpinner; |
||||
RecyclerView mRecyclerView; |
||||
Button mBtnNew; |
||||
Button mBtnCalc; |
||||
View layout_fit; |
||||
|
||||
private final int REQUEST_NEW_MATCHING_POINT = 100; |
||||
private RecyclerView.Adapter mAdapter; |
||||
private CoordinateSystem coordinateSystem; |
||||
private int from = -1; |
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity") |
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
setContentView(Rlayout.activity_point_correct()); |
||||
bindView(); |
||||
setSupportActionBar(mToolbar); |
||||
if (getSupportActionBar() != null) |
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||
|
||||
// Layout Managers:
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); |
||||
|
||||
// Item Decorator:
|
||||
mRecyclerView.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(this, Rdrawable.list_divider()))); |
||||
// mRecyclerView.setItemAnimator(new FadeInLeftAnimator());
|
||||
|
||||
//如果准备好后初始化UI
|
||||
// cachedCoordinateSystem.observe(new AbstractCachedObserver<CoordinateSystem>() {
|
||||
// @Override
|
||||
// public void onChanged(boolean isFirstTimeDataChanged, CoordinateSystem cs) {
|
||||
// if (coordinateSystem == null) {
|
||||
// init(cs);
|
||||
// }
|
||||
// coordinateSystem = cs;
|
||||
//
|
||||
// //监听坐标系变化,及时更新数据
|
||||
// mAdapter = new MatchingPointRecyclerViewAdapter(RtkPointCorrectActivity.this, coordinateSystem);
|
||||
// mRecyclerView.setAdapter(mAdapter);
|
||||
// }
|
||||
// });
|
||||
observeCurrentCoordinate(instance -> { |
||||
if (coordinateSystem == null) { |
||||
init(instance); |
||||
} |
||||
coordinateSystem = instance; |
||||
|
||||
//监听坐标系变化,及时更新数据
|
||||
mAdapter = newMatchingPointRecyclerViewAdapter(this, coordinateSystem); |
||||
mRecyclerView.setAdapter(mAdapter); |
||||
}); |
||||
} |
||||
|
||||
private void init(CoordinateSystem system) { |
||||
coordinateSystem = system; |
||||
mTransMethodSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, |
||||
new String[]{getString(Rstring.tgo_method()), getString(Rstring.four_parameters()), getString(Rstring.seven_parameters()), getString(Rstring.seven_parameters_strict())})); |
||||
mFitMethodSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, |
||||
new String[]{getString(Rstring.fixed_correction()), getString(Rstring.plane_fitting()), getString(Rstring.surface_fitting()), getString(Rstring.tgo_fitting())})); |
||||
switch (coordinateSystem.hFitting) { |
||||
case FIX: |
||||
mFitMethodSpinner.setSelection(0); |
||||
break; |
||||
case PLANE: |
||||
mFitMethodSpinner.setSelection(1); |
||||
break; |
||||
case CURVE: |
||||
mFitMethodSpinner.setSelection(2); |
||||
break; |
||||
default://TGO
|
||||
mFitMethodSpinner.setSelection(3); |
||||
} |
||||
|
||||
mTransMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
||||
@Override |
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
||||
switch (position) { |
||||
case 0: |
||||
case 1: |
||||
layout_fit.setVisibility(View.VISIBLE); |
||||
break; |
||||
case 2: |
||||
case 3: |
||||
layout_fit.setVisibility(View.GONE); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onNothingSelected(AdapterView<?> parent) { |
||||
|
||||
} |
||||
}); |
||||
if (coordinateSystem.grid != GridEnum.NULL) { |
||||
switch (coordinateSystem.grid) { |
||||
case FOUR_PARA: |
||||
mTransMethodSpinner.setSelection(1); |
||||
break; |
||||
default: |
||||
mTransMethodSpinner.setSelection(0); |
||||
} |
||||
} else if (coordinateSystem.datum != DatumEnum.NULL) { |
||||
if (coordinateSystem.datum == DatumEnum.STRICT) { |
||||
mTransMethodSpinner.setSelection(3); |
||||
|
||||
} else { |
||||
mTransMethodSpinner.setSelection(2); |
||||
} |
||||
} else { |
||||
mTransMethodSpinner.setSelection(0); |
||||
} |
||||
|
||||
mBtnNew.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View view) { |
||||
// Intent intent = new Intent(RtkPointCorrectActivity.this, RtkMatchingPointsActivity.class);
|
||||
// startActivityForResult(intent, REQUEST_NEW_MATCHING_POINT);
|
||||
startRtkMatchingPointsActivityForResult(REQUEST_NEW_MATCHING_POINT); |
||||
} |
||||
}); |
||||
mBtnCalc.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View view) { |
||||
if (mTransMethodSpinner.getSelectedItemPosition() == 0) { |
||||
calcPlaneTgoParas(); |
||||
} else if (mTransMethodSpinner.getSelectedItemPosition() == 1) { |
||||
try { |
||||
calcFourParas(); |
||||
} catch (ProjectionException exception) { |
||||
exception.printStackTrace(); |
||||
ToastUtils.showShort(getString(Rstring.illegal_value())); |
||||
} |
||||
} else { |
||||
try { |
||||
calcSevenParameters(); |
||||
} catch (InvalidValueException exception) { |
||||
exception.printStackTrace(); |
||||
ToastUtils.showShort(getString(Rstring.illegal_value()) + ":" + exception.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
//debug填充数据便于测试
|
||||
mBtnNew.setOnLongClickListener(new View.OnLongClickListener() { |
||||
@Override |
||||
public boolean onLongClick(View v) { |
||||
if (AppUtils.isAppDebug()) { |
||||
coordinateSystem.getPairs().clear(); |
||||
coordinateSystem.getPairs().add(new BlhCoordinatePair("", new Blh(Math.toDegrees(Util.dmsDoubleToRadian(29.2222341657)), Math.toDegrees(Util.dmsDoubleToRadian(116.0450543619)), -65.3234), new Coordinate(3250655.977, 507769.985, 49.082))); |
||||
coordinateSystem.getPairs().add(new BlhCoordinatePair("", new Blh(Math.toDegrees(Util.dmsDoubleToRadian(29.2208211327)), Math.toDegrees(Util.dmsDoubleToRadian(116.0452386143)), -74.3303), new Coordinate(3250220.9412, 507819.9756, 40.086))); |
||||
coordinateSystem.getPairs().add(new BlhCoordinatePair("", new Blh(Math.toDegrees(Util.dmsDoubleToRadian(29.2100500849)), Math.toDegrees(Util.dmsDoubleToRadian(116.0127564674)), -80.0736), new Coordinate(3248133.6936, 502296.3579, 34.57))); |
||||
mAdapter.notifyDataSetChanged(); |
||||
ThreadPoolUtil.execute(() -> { |
||||
// ProjectDb.getInstance().updateCurrentCoordinator(coordinateSystem);
|
||||
save(coordinateSystem); |
||||
}); |
||||
} |
||||
return true; |
||||
} |
||||
}); |
||||
|
||||
from = getIntent().getIntExtra("from", -1); |
||||
switch (from) { |
||||
case 1: |
||||
getSupportActionBar().setTitle(Rstring.parameter_calc()); |
||||
break; |
||||
case 4: |
||||
mTransMethodSpinner.setSelection(1); |
||||
mTransMethodSpinner.setEnabled(false); |
||||
getSupportActionBar().setTitle(Rstring.parameter_calc()); |
||||
break; |
||||
case 7: |
||||
mTransMethodSpinner.setSelection(2); |
||||
mTransMethodSpinner.setEnabled(false); |
||||
getSupportActionBar().setTitle(Rstring.parameter_calc()); |
||||
break; |
||||
} |
||||
if (from != 1) |
||||
new MaterialDialog.Builder(this) |
||||
.title(Rstring.hint()) |
||||
.content(Rstring.seven_or_four_para_hint()) |
||||
.positiveText(Rstring.go_to_config()) |
||||
.onPositive((dialog, which) -> { |
||||
// BingCeCoordinateSystemActivity.skip2ProjViewAndModifyCurrentCoordinateSystem(this);
|
||||
skip2ProjViewAndModifyCurrentCoordinateSystem(); |
||||
}) |
||||
.negativeText(Rstring.configured()) |
||||
.show(); |
||||
} |
||||
|
||||
private void calcPlaneTgoParas() { |
||||
int useH = 0, useV = 0; |
||||
for (int i = 0; i < coordinateSystem.getPairs().size(); i++) { |
||||
if (coordinateSystem.getPairs().get(i).isUseH()) |
||||
useH++; |
||||
if (coordinateSystem.getPairs().get(i).isUseV()) |
||||
useV++; |
||||
} |
||||
if (useH < 1) { |
||||
ToastUtils.showShort(Rstring.tgo_parameters_at_least_need_one_hor_matching_point()); |
||||
return; |
||||
} |
||||
switch (mFitMethodSpinner.getSelectedItemPosition()) { |
||||
case 0: |
||||
coordinateSystem.hFitting = HFittingEnum.FIX; |
||||
if (useV < 1) { |
||||
ToastUtils.showShort(Rstring.height_fix_fitting_at_least_need_one_vertical_matching_point()); |
||||
return; |
||||
} |
||||
break; |
||||
case 1: |
||||
coordinateSystem.hFitting = HFittingEnum.PLANE; |
||||
if (useV < 3) { |
||||
ToastUtils.showShort(Rstring.height_plane_fitting_at_least_need_three_vertical_matching_points()); |
||||
return; |
||||
} |
||||
break; |
||||
case 2: |
||||
coordinateSystem.hFitting = HFittingEnum.CURVE; |
||||
if (useV < 6) { |
||||
ToastUtils.showShort(Rstring.height_curve_fitting_at_least_need_six_vertical_matching_points()); |
||||
return; |
||||
} |
||||
break; |
||||
default: |
||||
coordinateSystem.hFitting = HFittingEnum.TGO; |
||||
if (useV < 1) { |
||||
ToastUtils.showShort(Rstring.height_tgo_fitting_at_least_need_one_vertical_matching_point()); |
||||
return; |
||||
} |
||||
} |
||||
PlaneTgoParaResult planeResult = CoorConverter.calcPlaneTgoPara(coordinateSystem, coordinateSystem.getPairs()); |
||||
HFitParaResult hFitResult = CoorConverter.calcHFittingPara(coordinateSystem, coordinateSystem.getPairs()); |
||||
if (planeResult != null && hFitResult != null) { |
||||
String tgoResultStr = getString(Rstring.tgo_parameters()) + "\n" |
||||
+ getString(Rstring.tgo_parameters_basex()) + ":" + Util.formatDouble2String(planeResult.getBaseX(), 6) + "\n" |
||||
+ getString(Rstring.tgo_parameters_basey()) + ":" + Util.formatDouble2String(planeResult.getBaseY(), 6) + "\n" |
||||
+ getString(Rstring.tgo_parameters_dx()) + ":" + Util.formatDouble2String(planeResult.getDx(), 6) + "\n" |
||||
+ getString(Rstring.tgo_parameters_dy()) + ":" + Util.formatDouble2String(planeResult.getDy(), 6) + "\n" |
||||
+ getString(Rstring.tgo_parameters_rotate()) + ":" + Util.radianToDmsString(planeResult.getRotate(), 6, false) + "\n" |
||||
+ getString(Rstring.tgo_parameters_k()) + ":" + Util.formatDouble2String(planeResult.getScale(), 18); |
||||
String fittingResultStr = getString(Rstring.elevation_fitting()) + "\n"; |
||||
if (hFitResult.gethFitType() == HFittingEnum.TGO) {//TGO高程拟合
|
||||
fittingResultStr += "北原点:" + Util.formatDouble2String(hFitResult.gethFitNorthOrigin(), 4) + "\n" + |
||||
"东原点:" + Util.formatDouble2String(hFitResult.gethFitEastOrigin(), 4) + "\n" + |
||||
"北斜坡(ppm):" + Util.formatDouble2String(hFitResult.gethFitNorthSlope(), 10) + "\n" + |
||||
"东斜坡(ppm):" + Util.formatDouble2String(hFitResult.gethFitEastSlope(), 10) + "\n" + |
||||
"高差常量:" + Util.formatDouble2String(hFitResult.gethFitHdConstant(), 4) + "\n"; |
||||
} else { |
||||
fittingResultStr += "A0:" + Util.formatDouble2String(hFitResult.gethFitA0(), 6) + "\n" + |
||||
"A1:" + Util.formatDouble2String(hFitResult.gethFitA1(), 10) + "\n" + |
||||
"A2:" + Util.formatDouble2String(hFitResult.gethFitA2(), 10) + "\n" + |
||||
"A3:" + Util.formatDouble2String(hFitResult.gethFitA3(), 15) + "\n" + |
||||
"A4:" + Util.formatDouble2String(hFitResult.gethFitA4(), 15) + "\n" + |
||||
"A5:" + Util.formatDouble2String(hFitResult.gethFitA5(), 15) + "\n" + |
||||
getString(Rstring.elevation_fitting_base_n()) + ":" + Util.formatDouble2String(hFitResult.gethFitN(), 6) + "\n" + |
||||
getString(Rstring.elevation_fitting_base_e()) + ":" + Util.formatDouble2String(hFitResult.gethFitE(), 6); |
||||
} |
||||
|
||||
StringBuilder residualString = new StringBuilder(getString(Rstring.residual()) + "(" + getString(Rstring.unit()) + ":m):\n"); |
||||
for (int i = 0; i < planeResult.getRmsList().size(); i++) { |
||||
if (planeResult.getRmsList().get(i) == null && hFitResult.getRmsList().get(i) == null) |
||||
continue; |
||||
residualString.append(getString(Rstring.zh_di())).append(i + 1) |
||||
.append(getString(Rstring.row_point())).append(":\n"); |
||||
if (planeResult.getRmsList().get(i) != null) { |
||||
double residualPlan = Math.sqrt(Math.pow(planeResult.getRmsList().get(i).getX(), 2) + Math.pow(planeResult.getRmsList().get(i).getY(), 2)); |
||||
residualString.append(getString(Rstring.transverse_residual())) |
||||
.append("=") |
||||
.append(Util.formatDouble2StringDotAuto(residualPlan)) |
||||
.append(residualPlan > 0.05 ? "(" + getString(Rstring.residual_overrun()) + ")\n" : "\n"); |
||||
} |
||||
if (hFitResult.getRmsList().get(i) != null) { |
||||
residualString.append(getString(Rstring.vertical_residual())).append("=") |
||||
.append(Util.formatDouble2StringDotAuto(hFitResult.getRmsList().get(i).getX())) |
||||
.append(Math.abs(hFitResult.getRmsList().get(i).getX()) > 0.05 ? "(" + getString(Rstring.residual_overrun()) + ")\n" : "\n"); |
||||
} |
||||
} |
||||
|
||||
new MaterialDialog.Builder(this) |
||||
.title(Rstring.tgo_parameters_elevation_fitting_result()) |
||||
.content(tgoResultStr + "\n" + fittingResultStr + "\n" + residualString + "\n" |
||||
+ (planeResult.getRmsList().size() == 2 ? getString(Rstring.point_pair_number_is_better_more_than_two()) : "")) |
||||
.positiveText(Rstring.global_apply()) |
||||
.onPositive(new MaterialDialog.SingleButtonCallback() { |
||||
@Override |
||||
public void onClick(MaterialDialog dialog, DialogAction which) { |
||||
coordinateSystem.useRtcm = false; |
||||
coordinateSystem.datum = DatumEnum.NULL; |
||||
coordinateSystem.grid = GridEnum.TGO; |
||||
coordinateSystem.tgoBaseX = planeResult.getBaseX(); |
||||
coordinateSystem.tgoBaseY = planeResult.getBaseY(); |
||||
coordinateSystem.tgoDx = planeResult.getDx(); |
||||
coordinateSystem.tgoDy = planeResult.getDy(); |
||||
coordinateSystem.tgoRot = Util.radianToDmsDouble(planeResult.getRotate(), false); |
||||
coordinateSystem.tgoScl = planeResult.getScale(); |
||||
if (hFitResult.gethFitType() == HFittingEnum.TGO) { |
||||
coordinateSystem.hFitNorthOrigin = hFitResult.gethFitNorthOrigin(); |
||||
coordinateSystem.hFitEastOrigin = hFitResult.gethFitEastOrigin(); |
||||
coordinateSystem.hFitNorthSlope = hFitResult.gethFitNorthSlope(); |
||||
coordinateSystem.hFitEastSlope = hFitResult.gethFitEastSlope(); |
||||
coordinateSystem.hFitHdConstant = hFitResult.gethFitHdConstant(); |
||||
} else { |
||||
coordinateSystem.hFitA0 = hFitResult.gethFitA0(); |
||||
coordinateSystem.hFitA1 = hFitResult.gethFitA1(); |
||||
coordinateSystem.hFitA2 = hFitResult.gethFitA2(); |
||||
coordinateSystem.hFitA3 = hFitResult.gethFitA3(); |
||||
coordinateSystem.hFitA4 = hFitResult.gethFitA4(); |
||||
coordinateSystem.hFitA5 = hFitResult.gethFitA5(); |
||||
coordinateSystem.hFitN = hFitResult.gethFitN(); |
||||
coordinateSystem.hFitE = hFitResult.gethFitE(); |
||||
} |
||||
coordinateSystem.correctN = 0; |
||||
coordinateSystem.correctE = 0; |
||||
coordinateSystem.correctH = 0; |
||||
ThreadPoolUtil.execute(() -> { |
||||
// ProjectDb.getInstance().updateCurrentCoordinator(coordinateSystem);
|
||||
save(coordinateSystem); |
||||
runOnUiThread(() -> { |
||||
ToastUtils.showShort(Rstring.apply_success()); |
||||
if (from == 1) { |
||||
EventBus.getDefault().post(new UpdateCoordinateSystemEvent()); |
||||
setResult(RESULT_OK); |
||||
finish(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
}) |
||||
.negativeText(Rstring.close()) |
||||
.show(); |
||||
} else { |
||||
ToastUtils.showShort(Rstring.transform_fail()); |
||||
} |
||||
} |
||||
|
||||
private void calcFourParas() { |
||||
int useH = 0, useV = 0; |
||||
for (int i = 0; i < coordinateSystem.getPairs().size(); i++) { |
||||
if (coordinateSystem.getPairs().get(i).isUseH()) |
||||
useH++; |
||||
if (coordinateSystem.getPairs().get(i).isUseV()) |
||||
useV++; |
||||
} |
||||
if (useH < 1) { |
||||
ToastUtils.showShort(Rstring.four_parameters_at_least_need_one_matching_point()); |
||||
return; |
||||
} |
||||
switch (mFitMethodSpinner.getSelectedItemPosition()) { |
||||
case 0: |
||||
coordinateSystem.hFitting = HFittingEnum.FIX; |
||||
if (useV < 1) { |
||||
ToastUtils.showShort(Rstring.height_fix_fitting_at_least_need_one_vertical_matching_point()); |
||||
return; |
||||
} |
||||
break; |
||||
case 1: |
||||
coordinateSystem.hFitting = HFittingEnum.PLANE; |
||||
if (useV < 3) { |
||||
ToastUtils.showShort(Rstring.height_plane_fitting_at_least_need_three_vertical_matching_points()); |
||||
return; |
||||
} |
||||
break; |
||||
case 2: |
||||
coordinateSystem.hFitting = HFittingEnum.CURVE; |
||||
if (useV < 6) { |
||||
ToastUtils.showShort(Rstring.height_curve_fitting_at_least_need_six_vertical_matching_points()); |
||||
return; |
||||
} |
||||
break; |
||||
default: |
||||
coordinateSystem.hFitting = HFittingEnum.TGO; |
||||
if (useV < 1) { |
||||
ToastUtils.showShort(Rstring.height_tgo_fitting_at_least_need_one_vertical_matching_point()); |
||||
return; |
||||
} |
||||
} |
||||
FourParaResult fourResult = CoorConverter.calc4Para(coordinateSystem, coordinateSystem.getPairs()); |
||||
HFitParaResult hFitResult = CoorConverter.calcHFittingPara(coordinateSystem, coordinateSystem.getPairs()); |
||||
if (fourResult != null && hFitResult != null) { |
||||
String fourResultStr = getString(Rstring.four_parameters()) + "\n" |
||||
+ getString(Rstring.four_parameters_dx()) + ":" + Util.formatDouble2String(fourResult.getDx(), 6) + "\n" |
||||
+ getString(Rstring.four_parameters_dy()) + ":" + Util.formatDouble2String(fourResult.getDy(), 6) + "\n" |
||||
+ getString(Rstring.four_parameters_rotate()) + ":" + Util.radianToDmsString(fourResult.getRotate(), 6, false) + "\n" |
||||
+ getString(Rstring.four_parameters_k()) + ":" + Util.formatDouble2String(fourResult.getScale(), 18); |
||||
String fittingResultStr = getString(Rstring.elevation_fitting()) + "\n"; |
||||
if (hFitResult.gethFitType() == HFittingEnum.TGO) {//TGO高程拟合
|
||||
fittingResultStr += "北原点:" + Util.formatDouble2String(hFitResult.gethFitNorthOrigin(), 4) + "\n" + |
||||
"东原点:" + Util.formatDouble2String(hFitResult.gethFitEastOrigin(), 4) + "\n" + |
||||
"北斜坡(ppm):" + Util.formatDouble2String(hFitResult.gethFitNorthSlope(), 10) + "\n" + |
||||
"东斜坡(ppm):" + Util.formatDouble2String(hFitResult.gethFitEastSlope(), 10) + "\n" + |
||||
"高差常量:" + Util.formatDouble2String(hFitResult.gethFitHdConstant(), 4) + "\n"; |
||||
} else { |
||||
fittingResultStr += "A0:" + Util.formatDouble2String(hFitResult.gethFitA0(), 6) + "\n" + |
||||
"A1:" + Util.formatDouble2String(hFitResult.gethFitA1(), 10) + "\n" + |
||||
"A2:" + Util.formatDouble2String(hFitResult.gethFitA2(), 10) + "\n" + |
||||
"A3:" + Util.formatDouble2String(hFitResult.gethFitA3(), 15) + "\n" + |
||||
"A4:" + Util.formatDouble2String(hFitResult.gethFitA4(), 15) + "\n" + |
||||
"A5:" + Util.formatDouble2String(hFitResult.gethFitA5(), 15) + "\n" + |
||||
getString(Rstring.elevation_fitting_base_n()) + ":" + Util.formatDouble2String(hFitResult.gethFitN(), 6) + "\n" + |
||||
getString(Rstring.elevation_fitting_base_e()) + ":" + Util.formatDouble2String(hFitResult.gethFitE(), 6); |
||||
} |
||||
StringBuilder residualString = new StringBuilder(getString(Rstring.residual()) + "(" + getString(Rstring.unit()) + ":m):\n"); |
||||
for (int i = 0; i < fourResult.getRmsList().size(); i++) { |
||||
if (fourResult.getRmsList().get(i) == null && hFitResult.getRmsList().get(i) == null) |
||||
continue; |
||||
residualString.append(getString(Rstring.zh_di())).append(i + 1) |
||||
.append(getString(Rstring.row_point())).append(":\n"); |
||||
if (fourResult.getRmsList().get(i) != null) { |
||||
double residualPlan = Math.sqrt(Math.pow(fourResult.getRmsList().get(i).getX(), 2) + Math.pow(fourResult.getRmsList().get(i).getY(), 2)); |
||||
residualString.append(getString(Rstring.transverse_residual())) |
||||
.append("=") |
||||
.append(Util.formatDouble2StringDotAuto(residualPlan)) |
||||
.append(residualPlan > 0.05 ? "(" + getString(Rstring.residual_overrun()) + ")\n" : "\n"); |
||||
} |
||||
if (hFitResult.getRmsList().get(i) != null) { |
||||
residualString.append(getString(Rstring.vertical_residual())).append("=") |
||||
.append(Util.formatDouble2StringDotAuto(hFitResult.getRmsList().get(i).getX())) |
||||
.append(Math.abs(hFitResult.getRmsList().get(i).getX()) > 0.05 ? "(" + getString(Rstring.residual_overrun()) + ")\n" : "\n"); |
||||
} |
||||
} |
||||
|
||||
new MaterialDialog.Builder(this) |
||||
.title(Rstring.four_parameters_elevation_fitting_result()) |
||||
.content(fourResultStr + "\n" + fittingResultStr + "\n" + residualString + "\n" |
||||
+ (fourResult.getRmsList().size() == 2 ? getString(Rstring.point_pair_number_is_better_more_than_two()) : "")) |
||||
.positiveText(Rstring.global_apply()) |
||||
.onPositive(new MaterialDialog.SingleButtonCallback() { |
||||
@Override |
||||
public void onClick(MaterialDialog dialog, DialogAction which) { |
||||
coordinateSystem.useRtcm = false; |
||||
coordinateSystem.datum = DatumEnum.NULL; |
||||
coordinateSystem.grid = GridEnum.FOUR_PARA; |
||||
coordinateSystem.fourDx = fourResult.getDx(); |
||||
coordinateSystem.fourDy = fourResult.getDy(); |
||||
coordinateSystem.fourRot = Util.radianToDmsDouble(fourResult.getRotate(), false); |
||||
coordinateSystem.fourScl = fourResult.getScale(); |
||||
if (hFitResult.gethFitType() == HFittingEnum.TGO) { |
||||
coordinateSystem.hFitNorthOrigin = hFitResult.gethFitNorthOrigin(); |
||||
coordinateSystem.hFitEastOrigin = hFitResult.gethFitEastOrigin(); |
||||
coordinateSystem.hFitNorthSlope = hFitResult.gethFitNorthSlope(); |
||||
coordinateSystem.hFitEastSlope = hFitResult.gethFitEastSlope(); |
||||
coordinateSystem.hFitHdConstant = hFitResult.gethFitHdConstant(); |
||||
} else { |
||||
coordinateSystem.hFitA0 = hFitResult.gethFitA0(); |
||||
coordinateSystem.hFitA1 = hFitResult.gethFitA1(); |
||||
coordinateSystem.hFitA2 = hFitResult.gethFitA2(); |
||||
coordinateSystem.hFitA3 = hFitResult.gethFitA3(); |
||||
coordinateSystem.hFitA4 = hFitResult.gethFitA4(); |
||||
coordinateSystem.hFitA5 = hFitResult.gethFitA5(); |
||||
coordinateSystem.hFitN = hFitResult.gethFitN(); |
||||
coordinateSystem.hFitE = hFitResult.gethFitE(); |
||||
} |
||||
coordinateSystem.correctN = 0; |
||||
coordinateSystem.correctE = 0; |
||||
coordinateSystem.correctH = 0; |
||||
ThreadPoolUtil.execute(() -> { |
||||
// ProjectDb.getInstance().updateCurrentCoordinator(coordinateSystem);
|
||||
save(coordinateSystem); |
||||
runOnUiThread(() -> { |
||||
ToastUtils.showShort(Rstring.apply_success()); |
||||
if (from == 1) { |
||||
EventBus.getDefault().post(new UpdateCoordinateSystemEvent()); |
||||
setResult(RESULT_OK); |
||||
finish(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
}) |
||||
.negativeText(Rstring.close()) |
||||
.show(); |
||||
} else { |
||||
ToastUtils.showShort(Rstring.transform_fail()); |
||||
} |
||||
} |
||||
|
||||
private void calcSevenParameters() { |
||||
int use = 0; |
||||
for (int i = 0; i < coordinateSystem.getPairs().size(); i++) { |
||||
if (coordinateSystem.getPairs().get(i).isUseH() && coordinateSystem.getPairs().get(i).isUseV()) |
||||
use++; |
||||
} |
||||
if (use < 3) { |
||||
ToastUtils.showShort(Rstring.seven_parameters_at_least_need_three_horizontal_vertical_matching_points()); |
||||
return; |
||||
} |
||||
SevenParaResult result = CoorConverter.calc7Para(coordinateSystem, coordinateSystem.getPairs(), mTransMethodSpinner.getSelectedItemPosition() == 3 ? DatumEnum.STRICT : DatumEnum.BURSA); |
||||
if (result != null) { |
||||
StringBuilder residualString = new StringBuilder(getString(Rstring.residual()) + "(" + getString(Rstring.unit()) + ":m):\n"); |
||||
for (int i = 0; i < result.getRmsList().size(); i++) { |
||||
double residualX = result.getRmsList().get(i).getX(); |
||||
double residualY = result.getRmsList().get(i).getY(); |
||||
double residualZ = result.getRmsList().get(i).getZ(); |
||||
double residualPlan = Math.sqrt(Math.pow(residualX, 2) + Math.pow(residualY, 2)); |
||||
residualString.append(getString(Rstring.zh_di())) |
||||
.append(i + 1) |
||||
.append(getString(Rstring.row_point())) |
||||
.append(":\n") |
||||
.append(getString(Rstring.transverse_residual())) |
||||
.append("=") |
||||
.append(Util.formatDouble2StringDotAuto(residualPlan)) |
||||
.append(residualPlan > 0.05 ? "(" + getString(Rstring.residual_overrun()) + ")\n" : "\n") |
||||
.append(getString(Rstring.vertical_residual())).append("=") |
||||
.append(Util.formatDouble2StringDotAuto(residualZ)) |
||||
.append(Math.abs(residualZ) > 0.05 ? "(" + getString(Rstring.residual_overrun()) + ")\n" : "\n"); |
||||
} |
||||
String sevenResult = getString(Rstring.seven_parameters_dx()) + ":" + Util.formatDouble2String(result.getDx(), 6) + "\n" |
||||
+ getString(Rstring.seven_parameters_dy()) + ":" + Util.formatDouble2String(result.getDy(), 6) + "\n" |
||||
+ getString(Rstring.seven_parameters_dz()) + ":" + Util.formatDouble2String(result.getDz(), 6) + "\n" |
||||
+ getString(Rstring.seven_parameters_rx()) + ":" + Util.formatDouble2String(result.getRx(), 8) + "\n" |
||||
+ getString(Rstring.seven_parameters_ry()) + ":" + Util.formatDouble2String(result.getRy(), 8) + "\n" |
||||
+ getString(Rstring.seven_parameters_rz()) + ":" + Util.formatDouble2String(result.getRz(), 8) + "\n" |
||||
+ getString(Rstring.seven_parameters_ppm()) + ":" + Util.formatDouble2String(result.getPpm(), 8); |
||||
|
||||
new MaterialDialog.Builder(this) |
||||
.title(Rstring.seven_parameters_result()) |
||||
.content(sevenResult + "\n" + residualString) |
||||
.positiveText(Rstring.global_apply()) |
||||
.onPositive(new MaterialDialog.SingleButtonCallback() { |
||||
@Override |
||||
public void onClick(MaterialDialog dialog, DialogAction which) { |
||||
coordinateSystem.useRtcm = false; |
||||
coordinateSystem.datum = mTransMethodSpinner.getSelectedItemPosition() == 3 ? DatumEnum.STRICT : DatumEnum.BURSA; |
||||
coordinateSystem.grid = GridEnum.NULL; |
||||
coordinateSystem.hFitting = HFittingEnum.NULL; |
||||
coordinateSystem.sevenDx = result.getDx(); |
||||
coordinateSystem.sevenDy = result.getDy(); |
||||
coordinateSystem.sevenDz = result.getDz(); |
||||
coordinateSystem.sevenRx = result.getRx(); |
||||
coordinateSystem.sevenRy = result.getRy(); |
||||
coordinateSystem.sevenRz = result.getRz(); |
||||
coordinateSystem.sevenPpm = result.getPpm(); |
||||
coordinateSystem.correctN = 0; |
||||
coordinateSystem.correctE = 0; |
||||
coordinateSystem.correctH = 0; |
||||
ThreadPoolUtil.execute(() -> { |
||||
// ProjectDb.getInstance().updateCurrentCoordinator(coordinateSystem);
|
||||
save(coordinateSystem); |
||||
runOnUiThread(() -> { |
||||
ToastUtils.showShort(Rstring.apply_success()); |
||||
if (from == 1) { |
||||
EventBus.getDefault().post(new UpdateCoordinateSystemEvent()); |
||||
setResult(RESULT_OK); |
||||
finish(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
}) |
||||
.negativeText(Rstring.close()) |
||||
.show(); |
||||
|
||||
} else { |
||||
ToastUtils.showShort(Rstring.transform_fail()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(MenuItem item) { |
||||
switch (item.getItemId()) { |
||||
case android.R.id.home: |
||||
finish(); |
||||
break; |
||||
} |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
// @Override
|
||||
// protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
// super.onActivityResult(requestCode, resultCode, data);
|
||||
// if (requestCode == REQUEST_NEW_MATCHING_POINT && resultCode == RESULT_OK) {
|
||||
// coordinateSystem = RTK.getInstance().getCoordinateSystem();
|
||||
// mAdapter = new MatchingPointRecyclerViewAdapter(this, coordinateSystem.getPairs());
|
||||
// mRecyclerView.setAdapter(mAdapter);
|
||||
// }
|
||||
// }
|
||||
|
||||
/////////////////////////
|
||||
protected void bindView() { |
||||
mToolbar = findViewById(Rid.toolbar()); |
||||
mTransMethodSpinner = findViewById(Rid.activity_point_correct_spinner_transform_method()); |
||||
mFitMethodSpinner = findViewById(Rid.activity_point_correct_spinner_fit_method()); |
||||
mRecyclerView = findViewById(Rid.recycler_view_point_correct()); |
||||
mBtnNew = findViewById(Rid.activity_point_correct_btn_new_point_pair()); |
||||
mBtnCalc = findViewById(Rid.activity_point_correct_btn_calc()); |
||||
layout_fit = findViewById(Rid.activity_point_correct_layout_fit_method()); |
||||
} |
||||
|
||||
protected abstract void observeCurrentCoordinate(IOnSingleGetCallback<CoordinateSystem> callback); |
||||
|
||||
protected abstract AbstractMatchingPointRecyclerViewAdapter newMatchingPointRecyclerViewAdapter(Context context, CoordinateSystem coordinateSystem); |
||||
|
||||
protected abstract void startRtkMatchingPointsActivityForResult(int requestCode); |
||||
|
||||
protected abstract void skip2ProjViewAndModifyCurrentCoordinateSystem(); |
||||
|
||||
@WorkerThread |
||||
protected abstract void save(CoordinateSystem coordinateSystem); |
||||
} |
Loading…
Reference in new issue