question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create Projection classes instead of strings

See original GitHub issue

Description of the desired feature

The Figure methods take a projection argument that is using the same arguments as GMT -J ("M10i" for Mercator 10 inches). But a lot of projections have many arguments and it’s impossible to remember them all. A relatively simple alternative would be to implement classes (based on a single Projection class maybe) that take the projection arguments in the constructor (and so allows tab-completion). The key would be for these classes to define a __str__ method so that when str is called on them, they produce the GMT -J code. For example:

>>> proj = pygmt.Orthographic(central_longitude=10, central_latitude=52, width=10)
>>> print(str(proj))
G10/52/10

The plotting method pre-processing would only have to call str on projection, which works fine if you pass in a string as well.

Are you willing to help implement and maintain this feature? Yes but I’d welcome anyone else who wants to try 😃

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
sixy6ecommented, Nov 14, 2019

Hi everyone, I’m just having a quick exploration into this issue whilst at the FOSS4G Oceania Community Day.

I think attrs is a good idea, so I’ll prototype out something over the weekend and see what you think. I have used attrs in a similar fashion to what is being described in this issue.

0reactions
sixy6ecommented, Feb 12, 2021

I’ll try to squish some time in and push through the last bits of the this over the next few weeks. Spare time completely disappeared for me the past year.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create projection class for complex case class in slick?
I understand there is no way to automate or auto-generate this or any other slick classes definition from a regular case class.... Does...
Read more >
Defining Class Projections - InterSystems Documentation
This chapter discusses class projections, which provide a way to customize what happens when a class is compiled or removed.
Read more >
Spring Data JPA Projections - Baeldung
Let's declare a projection interface for the Address class: public interface AddressView { String getZipCode(); }
Read more >
Projection operations (C#) - Microsoft Learn
By using projection, you can construct a new type that is built from each object. You can project a property and perform a...
Read more >
3.1.1. Custom expressions - Querydsl
Projections class offers a set of factory methods for Bean, constructor, ... Instead of a direct Java cast, the supertype reference is accessible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found