Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Configure basemap style language sample #1688

Merged
merged 22 commits into from
Mar 6, 2024

Conversation

har13205
Copy link
Collaborator

@har13205 har13205 commented Mar 2, 2024

Description

This PR is to add Configure basemap style language sample

Type of change

  • Bug fix
  • New sample implementation
  • Sample viewer enhancement
  • Other enhancement

Platforms tested on:

  • Windows
  • Android
  • Linux
  • macOS
  • iOS

Checklist

  • Runs and compiles on all active platforms as a standalone sample
  • Runs and compiles in the sample viewer(s)
  • Branch is up to date with the latest main/v.next
  • All merge conflicts have been resolved
  • Self-review of changes
  • There are no warnings related to changes
  • No unrelated changes have been made to any other code or project files
  • Code is commented with correct formatting (CTRL+i)
  • All variable and method names are camel case
  • There is no leftover commented code
  • Screenshots are correct size and display in description tab (500px by 500px, platform agnostic)
  • If adding a new sample, it is added to the sample viewer
  • Cherry-picked to Main branch (if applicable)

@har13205 har13205 self-assigned this Mar 2, 2024
Comment on lines 130 to 131
function setNewBasemap() {
model.setNewBasemap(globalButton.checked , comboBox.currentText);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably both should have a clearer name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screenshot proportions don't look correct. It looks like it's been squished.

basemapStyleParameters->setLanguageStrategy(global? BasemapStyleLanguageStrategy::Global : BasemapStyleLanguageStrategy::Local);

//A SpecificLanguage setting overrides the LanguageStrategy settings
if (language == "none") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review bracket style.

}
}

function setNewBasemap() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unnecessary to have the JS function wrapping the C++ function - why not just directly call the C++ function from the combobox itself?

har13205 and others added 10 commits March 4, 2024 14:57
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.h

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.qml

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
Copy link
Contributor

@JamesMBallard JamesMBallard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, but I noticed a few other minor things.

{
if (!basemapStyleParameters)
{
basemapStyleParameters = new BasemapStyleParameters(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is always needed. If so, consider creating it in the constructor.

har13205 and others added 3 commits March 4, 2024 18:30
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: James Ballard <[email protected]>
@har13205 har13205 requested a review from JamesMBallard March 5, 2024 02:42
Copy link
Contributor

@ldanzinger ldanzinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I've got a couple more suggestions for cleanup

Comment on lines 60 to 67
connect(m_map, &Map::doneLoading, this, [](const Error& e)
{
if (!e.isEmpty())
{
qWarning() << e.message() << e.additionalMessage();
return;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably unnecessary to include checking in this logging for the map load status. I suggest removing it

har13205 and others added 5 commits March 5, 2024 10:00
…ge/ConfigureBasemapStyleLanguage.h

Co-authored-by: Lucas Danzinger <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: Lucas Danzinger <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: Lucas Danzinger <[email protected]>
…ge/ConfigureBasemapStyleLanguage.cpp

Co-authored-by: Lucas Danzinger <[email protected]>
@har13205 har13205 requested a review from ldanzinger March 5, 2024 18:16

ConfigureBasemapStyleLanguage::ConfigureBasemapStyleLanguage(QObject* parent /* = nullptr */) :
QObject(parent),
m_map(new Map(SpatialReference::webMercator())),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory leak

Suggested change
m_map(new Map(SpatialReference::webMercator())),
m_map(new Map(SpatialReference::webMercator(), this)),

Also, does the map initially launch empty until users press a button? That doesn't seem optimal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the map initially launches with local language strategy

// Set the view (created in QML)
void ConfigureBasemapStyleLanguage::setMapView(MapQuickView* mapView)
{
m_map = new Map(SpatialReference::webMercator());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done in the constructor.

Comment on lines 101 to 102
if (m_basemap)
delete m_basemap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (m_basemap)
delete m_basemap;
if (m_basemap)
m_basemap->deleteLater();

I think your code works fine, but conceptually it feels wrong to delete the map's basemap while it's still displayed. We could write a bunch of extra code to change the order, but deleteLater does the same thing with less code.

@har13205 har13205 requested a review from JamesMBallard March 5, 2024 18:41
Copy link
Contributor

@ldanzinger ldanzinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks like the design is approved and about to be merged. I think we might want to wait until it is officially merged before we merge this. You can watch the #native-samples-announcements channel for this

ComboBox {
id: comboBox
model: ["none" , "Bulgarian", "Greek", "Turkish"]
onCurrentTextChanged: model.setNewBasemapLanguage(globalButton.checked, comboBox.currentText);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our offline discussion, I think this should be more intentional. It seems this executes when the code first loads, but it's unclear from looking at the c++ code how any basemap was loaded. I think the code should be more intentional about how the initial basemap is being set.

When I reviewed the latest code, I assumed no basemap at all was set, because that's what is happening on the C++ side via the constructor.

@har13205 har13205 requested a review from JamesMBallard March 5, 2024 21:12
@har13205 har13205 merged commit 501830a into v.next Mar 6, 2024
1 check passed
@har13205 har13205 deleted the har13205/configureBasemapStyleLanguage branch March 6, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants